"Abu Mushayeed" <amushayeed@xxxxxxxxxxx> writes: > AFTER A WHILE THE SYSTEM COMES BACK AND SAYS IN THE LOG FILE: Please turn off your caps lock key :-( > AggContext: -1501569024 total in 351 blocks; 69904 free (507 chunks); > -1501638928 used > DynaHashTable: 302047256 total in 46 blocks; 275720 free (66 chunks); > 301771536 used Hm, it's evidently misjudging how much memory will be needed by a HashAggregate plan, probably because it's underestimating the number of GROUP BY groups. Could we see the EXPLAIN output for the query? What PG version is this exactly? Have you ANALYZEd the table lately? regards, tom lane