1

Is there a way to save postgres query output to multiple files.

I am using below query to save the output to a tab-separated file but it is taking really long.

psql "host= port= dbname= user= password=" -AF $'\t' --no-align -f splice_site_v1_23mer.sql -o 23mer.tsv

Thanks

rshar
  • 1,381
  • 10
  • 28
  • what does `splice_site_v1_23mer.sql` do? If you're using `psql`, couldn't you just process `splice_site_v1_23mer.sql` line-by-line, sending the output to a different file each time? – richyen Feb 11 '20 at 21:34
  • There is no reason to think saving to multiple files will make it faster. But you can use `\o` within the -f file (between queries, not within one) to change the output destination. – jjanes Feb 11 '20 at 22:36
  • @jjanes could you please explain it bit more (with example query)? Thanks – rshar Feb 11 '20 at 22:42
  • @richyen could you please explain how to send output to a different file each time? I am new to Postgres so not aware of it. The SQL query has couple of WITH statements and a select statement to get the final output. – rshar Feb 11 '20 at 22:45
  • Does this answer your question? [Split a big postgres table into multiple csv](https://stackoverflow.com/questions/60187391/split-a-big-postgres-table-into-multiple-csv) – JGH Feb 12 '20 at 13:13

0 Answers0