Re: Slow query when the select list is big

From: Karl Czajkowski <karlcz(at)isi(dot)edu>
To: Sterpu Victor <victor(at)caido(dot)ro>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Slow query when the select list is big
Date: 2016-05-09 17:47:12
Message-ID: 20160509174712.GB10193@moraine.isi.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On May 09, Sterpu Victor modulated:
> I tested it now, EXPLAIN ANALYZE is not showing LEFT JOIN at all if
> I don't select from the joined tables.
> Now is clear why the query is so mutch more efficient when I select
> less data.
>
> Thank you
>

With so many joins, you may want to experiment with postgresql
parameter tuning. These parameters in particular can have a
significant impact on the plan choice and execution time:

work_mem
effective_cache_size

from_collapse_limit
join_collapse_limit

geqo_threshold
geqo_effort

Setting these to appropriately large values can make analytic queries
run much faster. Of course, setting them too high can also make for
very bad plans which cause the DB server to over subscribe its memory
and start swapping... it requires a bit of reading and a bit of
experimentation to find ideal settings for your environment.

Karl

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert Anderson 2016-05-09 17:53:50 Re: Create index concurrently hanging with big table on pgsql 9.3.12
Previous Message Roman Khalupa 2016-05-09 17:46:03 Build postgresql