Re: [GENERAL] how to import "where exists(subquery)" EXISTS CONDITION performance? - Mailing list pgsql-general

From David Rowley
Subject Re: [GENERAL] how to import "where exists(subquery)" EXISTS CONDITION performance?
Date
Msg-id CAKJS1f-85jiy8HOZDnJpgF_ncHCSuhS_zbkmCOLUchr39hjTRg@mail.gmail.com
Whole thread Raw
In response to how to import "where exists(subquery)" EXISTS CONDITION performance?  (shili <shi_li_1992@163.com>)
List pgsql-general
On 2 December 2015 at 20:51, shili <shi_li_1992@163.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/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-general by date:

Previous
From: shili
Date:
Subject: how to import "where exists(subquery)" EXISTS CONDITION performance?
Next
From: "Peter J. Holzer"
Date:
Subject: Re: plperlu stored procedure seems to freeze for a minute