From: | David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> |
---|---|
To: | shili <shi_li_1992(at)163(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: [GENERAL] how to import "where exists(subquery)" EXISTS CONDITION performance? |
Date: | 2015-12-02 10:51:13 |
Message-ID: | CAKJS1f-85jiy8HOZDnJpgF_ncHCSuhS_zbkmCOLUchr39hjTRg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2 December 2015 at 20:51, shili <shi_li_1992(at)163(dot)com> wrote:
> I had saw this sentence: SQL statements that use the EXISTS condition in
> PostgreSQL are very inefficient since the sub-query is RE-RUN for EVERY row
> in the outer query's table. There are more efficient ways to write most
> queries, that do not use the EXISTS condition. So,I want to know how
> PostgreSQL to implement the EXISTS condition? Is that sentence true? and,if
> that is true,are there any methods to import the performance of the EXISTS
> condition?
That sounds like it might be quite out-dated information. Semi joins have
been supported for around 7 years.
However, there are cases where this is still not possible, for example if
the subquery contains a volatile function, or perhaps a LIMIT or OFFSET.
You can view the output from the planner by prefixing your SELECT statement
with EXPLAIN: See
http://www.postgresql.org/docs/current/static/sql-explain.html
This will give you the information you need to see how the query planner
has decided on how your query will be executed.
--
David Rowley http://www.2ndQuadrant.com/
<http://www.2ndquadrant.com/>
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Peter J. Holzer | 2015-12-02 15:26:14 | Re: plperlu stored procedure seems to freeze for a minute |
Previous Message | shili | 2015-12-02 07:51:23 | how to import "where exists(subquery)" EXISTS CONDITION performance? |