From: Tom Lane <tgl@sss.pgh.pa.us>
To: cadiolis@gmail.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Text->Date conversion in a WHERE clause
Date: Wed, 12 Oct 2005 19:00:05 -0400
Message-ID: <5023.1129158005@sss.pgh.pa.us> (raw)
In-Reply-To: <1129153075.962155.131260@g43g2000cwa.googlegroups.com>
References: <df01c91b0510121359m1d7e67b5n41ee4d939798b69b@mail.gmail.com>
<1129153075.962155.131260@g43g2000cwa.googlegroups.com>
cadiolis@gmail.com writes:
> SELECT *
> FROM
> (
> SELECT u.user_id, ud.data
> FROM users u, userdata ud
> WHERE u.user_id = ud.user_id
> AND u.type = 1
> ) subusers
> WHERE subusers.data::text::date < now();
> So my question is how does this query ever even SEE the row containing
> "052-44-5863"? The sub-query doesn't return that row so I don't see
> how it can get this error.
BTW, the fallacy in this idea is that the planner pushes WHERE clauses
as far down the plan tree as it can. EXPLAIN would show you the actual
plan tree, but it's probably along the lines of
Join using u.user_id = ud.user_id
Scan users u where u.type = 1
Scan userdata ud where ud.data::text::date < now();
If we did not do this, it would pretty much cripple the performance
of queries involving views (since a view is nothing but a macro for a
sub-select).
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, cadiolis@gmail.com
Subject: Re: Text->Date conversion in a WHERE clause
In-Reply-To: <5023.1129158005@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox