PostgreSQL – Dump Distinct Column Without High Memory Usage

copypostgresqlpsql

I'm trying to dump csv of distinct varchar(43) column to file, table has around billion rows, select distinct command either runs out of memory and command is aborted or server just closes all connections. Does PostgreSQL have built in methods for such task?

psql (10.9 (Ubuntu 10.9-0ubuntu0.18.10.1)) 16GB RAM

Best Answer

Solution suggested by jjanes worked, run set enable_hashagg=off in psql terminal