I stand corrected; I read through the example too quickly.
As I said, explain analyze would show what the difference is between the
two queries. I suspect that the planner doesn't know these are
equivalent, because in the general case of selecting more than just TRUE
they wouldn't be.
No idea why
NOT TRUE!
The second query is effectively "(SELECT TRUE ...WHERE ... LIMIT 1) OR
(SELECT TRUE ...WHERE ... LIMIT 1) AS ..."
The first portion in parentheses can return either a single row of TRUE,
or no row (NULL). Ditto for the second portion. The OR means that you
logically combine TRUEs
Those two queries aren't the same. The first one can only return 0 or 1 rows;
the second one can return 0, 1, or 2 rows.
An explain analyze of each should show why one is much faster than the
other.
On Mon, Oct 17, 2005 at 10:29:43AM -0700, Dean Gibson (DB Administrator) wrote:
> In the query bel
In the query below, if I replace:
(SELECT TRUE FROM archivejb WHERE ( (callsign = gen.callsign AND
license_status = 'A' AND prev_callsign = gen.vanity_callsign)
OR (callsign =
gen.vanity_callsign AND licensee_id =
gen.license