Re: [GENERAL] How does Postgres estimate the memory needed for sorting/aggregating

2017-01-25 Thread Tomas Vondra
On 01/25/2017 10:47 PM, John R Pierce wrote: On 1/25/2017 12:59 PM, Thomas Kellerer wrote: So here is my question: how does Postgres estimate/know the memory needed for the aggregation? Or does it dynamically resize the memory if the initial assumption was wrong? my understanding is it fits as

Re: [GENERAL] How does Postgres estimate the memory needed for sorting/aggregating

2017-01-25 Thread John R Pierce
On 1/25/2017 12:59 PM, Thomas Kellerer wrote: So here is my question: how does Postgres estimate/know the memory needed for the aggregation? Or does it dynamically resize the memory if the initial assumption was wrong? my understanding is it fits as much as it can into a work_mem sized alloca

Re: [GENERAL] How does Postgres estimate the memory needed for sorting/aggregating

2017-01-25 Thread Tomas Vondra
On 01/25/2017 09:59 PM, Thomas Kellerer wrote: There was a question on dba.stackexchange recently: http://dba.stackexchange.com/a/162117/1822 That question (and the answer) deals with performance difference of a query caused by the _declared_ length of a VARCHAR column in SQL Server (everyth

[GENERAL] How does Postgres estimate the memory needed for sorting/aggregating

2017-01-25 Thread Thomas Kellerer
There was a question on dba.stackexchange recently: http://dba.stackexchange.com/a/162117/1822 That question (and the answer) deals with performance difference of a query caused by the _declared_ length of a VARCHAR column in SQL Server (everything else being equal - especially the actual d