Re: Size of IN list affects query plan - Mailing list pgsql-performance

From bricklen
Subject Re: Size of IN list affects query plan
Date
Msg-id CAGrpgQ9jQe+=LYdWps_VOSxaR-yrGegsB4QeDW1uf-Ev==YLzA@mail.gmail.com
Whole thread Raw
In response to Size of IN list affects query plan  (Jan Walter <john@commontongue.com>)
List pgsql-performance

On Fri, Nov 8, 2013 at 6:04 AM, Jan Walter <john@commontongue.com> wrote:
Hi,

I would like to know, how does the size of the IN list affect query planner.
I have a query

select distinct on (event_id, tag_id) et.id,
       e.id as event_id, t.id as tag_id, t.name,
       t.user_id, t.shared, t.color,
       case
         when ea.id <> e.id then true
         else false
       end as inherited
from do_event e
     join do_event ea on (ea.tree_id = e.tree_id and ea.lft <= e.lft and ea.rght >= e.rght)
     join do_event_tags et on (et.event_id = ea.id)
     join do_tag t on (t.id = et.tag_id)
where e.id in (LIST_OF_INTEGERS) and
      (t.user_id = 14 or t.shared)
order by event_id, tag_id, inherited;


Looking at your EXPLAIN ANALYZE plan I was immediately reminded of this article http://www.datadoghq.com/2013/08/100x-faster-postgres-performance-by-changing-1-line/, where changing the array to a VALUES() clause was a huge win for them.

pgsql-performance by date:

Previous
From: Jan Walter
Date:
Subject: Size of IN list affects query plan
Next
From: Tom Lane
Date:
Subject: Re: Size of IN list affects query plan