How to read all rows from huge table?

前端 未结 6 1504
长发绾君心
长发绾君心 2020-11-28 03:11

I have a problem with processing all rows from database (PostgreSQL). I get an error: org.postgresql.util.PSQLException: Ran out of memory retrieving query results.

6条回答
  •  被撕碎了的回忆
    2020-11-28 03:40

    At lest in my case the problem was on the client that tries to fetch the results.

    Wanted to get a .csv with ALL the results.

    I found the solution by using

    psql -U postgres -d dbname  -c "COPY (SELECT * FROM T) TO STDOUT WITH DELIMITER ','"
    

    (where dbname the name of the db...) and redirecting to a file.

提交回复
热议问题