Re: Size of IN list affects query plan

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan Walter <john(at)commontongue(dot)com>
Cc: postgres performance list <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Size of IN list affects query plan
Date: 2013-11-08 14:31:42
Message-ID: 27470.1383921102@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Jan Walter <john(at)commontongue(dot)com> writes:
> I would like to know, how does the size of the IN list affect query planner.

AFAICT, the reason the second plan is slow is the large number of checks
of the IN list. The planner does account for the cost of that, but it's
drastically underestimating that cost relative to the cost of I/O for the
heap and index accesses. I suppose that your test case is fully cached in
memory, which helps make the CPU costs more important than I/O costs.
If you think this is representative of your real workload, then you
need to decrease random_page_cost (and maybe seq_page_cost too) to make
the cost estimates correspond better to that reality.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message bricklen 2013-11-08 14:31:49 Re: Size of IN list affects query plan
Previous Message Jan Walter 2013-11-08 14:04:55 Size of IN list affects query plan