Re: Increasing work_mem slows down query, why?

2020-03-30 Thread Silvio Moioli
On 3/30/20 8:56 AM, Pavel Stehule wrote: > please, can you send explain in text form? Sure. With work_mem = 80MB: QUERY PLAN

Re: Increasing work_mem slows down query, why?

2020-03-30 Thread Pavel Stehule
po 30. 3. 2020 v 10:12 odesílatel Silvio Moioli napsal: > On 3/30/20 8:56 AM, Pavel Stehule wrote: > > please, can you send explain in text form? > > Sure. With work_mem = 80MB: > > > QUERY PLAN > > -

Re: Increasing work_mem slows down query, why?

2020-03-30 Thread Silvio Moioli
On 3/30/20 12:12 PM, Pavel Stehule wrote: > Do you have some planner variables changed - like seq_page_cost? That one was not changed but another one is - cpu_tuple_cost (to 0.5). Indeed bringing it back to its default does improve the query time significantly:

Re: Increasing work_mem slows down query, why?

2020-03-30 Thread Pavel Stehule
po 30. 3. 2020 v 15:09 odesílatel Silvio Moioli napsal: > On 3/30/20 12:12 PM, Pavel Stehule wrote: > > Do you have some planner variables changed - like seq_page_cost? > > That one was not changed but another one is - cpu_tuple_cost (to 0.5). > Indeed bringing it back to its default does improve

Re: Increasing work_mem slows down query, why?

2020-03-30 Thread Pavel Stehule
> > Is that an unreasonable value? For the sake of this discussison, I am > targeting fairly average bare-metal SSD-backed servers with recent CPUs > (let's say 3 year old maximum), with ample available RAM. > if you have SSD, then you can decrease RANDOM_PAGE_COST to 2 maybe 1.5. But probably the

Re: Increasing work_mem slows down query, why?

2020-03-30 Thread Tom Lane
Pavel Stehule writes: > po 30. 3. 2020 v 10:12 odesílatel Silvio Moioli napsal: >> -> Sort (cost=299108.00..300335.41 rows=490964 width=79) >> (actual time=6475.147..6494.111 rows=462600 loops=1) >> Output: rhnpackagecapability_1.name, >> rhnpackagecapability_1.version,

Re: Increasing work_mem slows down query, why?

2020-03-30 Thread Pavel Stehule
po 30. 3. 2020 v 18:02 odesílatel Tom Lane napsal: > Pavel Stehule writes: > > po 30. 3. 2020 v 10:12 odesílatel Silvio Moioli napsal: > >> -> Sort (cost=299108.00..300335.41 rows=490964 width=79) > >> (actual time=6475.147..6494.111 rows=462600 loops=1) > >> Output: rhnpackag

Re: Increasing work_mem slows down query, why?

2020-03-30 Thread Tom Lane
Pavel Stehule writes: > CTE scan has only 1100 rows, public.rhnpackagecapability has 490964 rows. > But planner does hash from public.rhnpackagecapability table. It cannot be > very effective. [ shrug... ] Without stats on the CTE output, the planner is very leery of putting it on the inside of

Re: Increasing work_mem slows down query, why?

2020-03-30 Thread Pavel Stehule
po 30. 3. 2020 v 18:36 odesílatel Tom Lane napsal: > Pavel Stehule writes: > > CTE scan has only 1100 rows, public.rhnpackagecapability has 490964 > rows. > > But planner does hash from public.rhnpackagecapability table. It cannot > be > > very effective. > > [ shrug... ] Without stats on the