Re: [SQL] index usage ... strange !? - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] index usage ... strange !?
Date
Msg-id 22018.948148017@sss.pgh.pa.us
Whole thread Raw
In response to index usage ... strange !?  (Marten Feldtmann <marten@feki.toppoint.de>)
Responses Re: [SQL] index usage ... strange !?  (Marten Feldtmann <marten@feki.toppoint.de>)
List pgsql-sql
Marten Feldtmann <marten@feki.toppoint.de> writes:
>  SELECT AO,AT,AV FROM P3AT
>  WHERE EXISTS( SELECT AO FROM P3AT WHERE AV='12' AND AT=12 AND CI=17)

Um ... I dunno what you are trying to accomplish, but this query
almost certainly doesn't do what you want.  Since the inner query
is independent of the outer, you will get back either all the rows
of P3AT (if the inner query yields rows) or none (if it doesn't).

The plan you quote is perfectly reasonable for this query...
the machine is even bright enough to figure out that it only
needs to evaluate the subquery once.
        regards, tom lane


pgsql-sql by date:

Previous
From: Marten Feldtmann
Date:
Subject: index usage ... strange !?
Next
From: Michael McCarthy
Date:
Subject: ordering operator for bytea