How to load only some of the tables from PostgreSQL?
Closed this issue · 4 comments
Hi, I'm using TPC-H benchmark on PostgreSQL.
I want to load only some of tables into duckdb (e.g., orders), the others are loaded from pg_scanner.
So I first load data into duckdb, and then use postgres_attach to load the other tables from PostgreSQL.
cursor.execute("CREATE TABLE orders as (SELECT * FROM postgres_scan_pushdown('host={} user={} "
"dbname={} port={}','public','orders'));")
cursor.execute("CALL postgres_attach('host={} user={} "
"dbname={} port={}', filter_pushdown=false);")
Then I got the exception "Failed to create view 'orders': View with name "orders" already exists!"
I wonder what can I do to load tables except "orders" from scanner, (i.e., skipping existing tables.)
Thanks~
postgres_attach creates views for each table in the system. Perhaps you could run postgres_attach first and then drop the ORDERS view?
postgres_attach creates views for each table in the system. Perhaps you could run postgres_attach first and then drop the ORDERS view?
Oh, it works~Thank you very much!!!
By the way, how can I get each column size stored in duckdb?
I can use pg_total_relation_size to get the size from PostgreSQL, but how can I get this from duckdb?
SELECT table_schema || '.' || table_name AS table_full_name, pg_size_pretty(pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')) AS size
FROM information_schema.tables
ORDER BY
pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') DESC;
I believe this pragma has the info you are looking for!
PRAGMA table_info('table_name');In the future, please create a new issue!
I believe this pragma has the info you are looking for!
PRAGMA table_info('table_name');In the future, please create a new issue!
Thanks for your reply! But perhaps this pragma is not I'm looking for.
Sorry about that, and I'll create a new issue to claim this issue. ^_^
