From: | Mathieu De Zutter <mathieu(at)dezutter(dot)org> |
---|---|
To: | pgsql-performance <pgsql-performance(at)postgresql(dot)org> |
Subject: | Query plan change with multiple elements in IN clause |
Date: | 2013-08-30 09:05:46 |
Message-ID: | CAH7GKCzV_ZSBodUaT9ui406o-0Ak9WNHWW=yCMThj8CE_QJXQQ@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Hi all,
I'm migrating a web application to an ORM framework (Doctrine) so I need a
new way to get statistics about entities into the application without
importing all data, only the results (e.g. load total number of children
instead of loading all children into the application and counting it
afterwards). My current solution is to create a view for those statistics
and map it to an (read-only) entity in my application. This view is joined
with the table containing the entities on which I need statistics.
The entity table is called 'work'. The view containing statistical
information about works is called wps2.
The problem is that this join is performing very badly when more than one
work is involved. It chooses a plan that is orders of magnitude slower.
I have attached
- The (simplified) table definitions
- The (simplified) view
- Two queries with explain analyze plan: "IN (1)" => fast, "IN (1,3)" =>
slow
- postgresql.conf
I do not understand why the planner does not consider the nested loop in
the second case, like it does in the first case.
Can anyone help me?
Thanks.
Kind regards,
Mathieu
Attachment | Content-Type | Size |
---|---|---|
wps.txt | text/plain | 24.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2013-08-30 14:00:28 | Re: Query plan change with multiple elements in IN clause |
Previous Message | Bastiaan Olij | 2013-08-30 02:22:15 | Optimising views |