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