Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to insert load / into cstore foreign tables in order #248

Open
rameshkaranth opened this issue Apr 13, 2021 · 1 comment
Open

How to insert load / into cstore foreign tables in order #248

rameshkaranth opened this issue Apr 13, 2021 · 1 comment

Comments

@rameshkaranth
Copy link

rameshkaranth commented Apr 13, 2021

Hey team,

I read in the documentation of cstore_fdw that while loading data into cstore foreign table after sorting it on a column that is commonly used in the WHERE clause.

I am using a COPY from CSV to load the data in cstore foreign table like below

\COPY (SELECT * FROM tbl_metrics_partition_2020_q3 WHERE report_date >= '2020-09-01' AND report_date <= '2020-09-30') TO 'tbl_metrics_partition_fdw_2020_m9.csv' CSV DELIMITER ',' HEADER

\COPY tbl_metrics_partition_fdw_2020_m9 FROM 'tbl_metrics_partition_fdw_2020_m9.csv' CSV DELIMITER ',' HEADER
  • If I add a order by in the select statement when creating the CSV file, will the copy command to the cstore table insert into order?
@ljluestc
Copy link

-- Create a CSV file with data sorted by a column commonly used in the WHERE clause
\COPY (
    SELECT * FROM tbl_metrics_partition_2020_q3 
    WHERE report_date >= '2020-09-01' AND report_date <= '2020-09-30'
    ORDER BY report_date -- Add ORDER BY clause here
) TO 'tbl_metrics_partition_fdw_2020_m9.csv' CSV DELIMITER ',' HEADER;

-- Copy the data from the CSV file into the cstore foreign table
\COPY tbl_metrics_partition_fdw_2020_m9 FROM 'tbl_metrics_partition_fdw_2020_m9.csv' CSV DELIMITER ',' HEADER;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants