On Fri, Nov 8, 2013 at 6:04 AM, Jan Walter <j...@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.

Reply via email to