Re: Outer where pushed down

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gaetano Mendola <mendola(at)bigfoot(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Outer where pushed down
Date: 2005-10-06 13:24:54
Message-ID: 16627.1128605094@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gaetano Mendola <mendola(at)bigfoot(dot)com> writes:
> CREATE OR REPLACE VIEW v_current_connection AS
> SELECT ul.id_user
> FROM user_login ul,
> current_connection cc
> WHERE ul.id_user = cc.id_user;

> # explain select * from v_current_connection_test where sp_connected_test(id_user) = FALSE;

> why postgres doesn't apply that function at table current_connection given the fact are extimated
> only 919 vs 27024 rows?

Because the condition is on a field of the other table.

You seem to wish that the planner would use "ul.id_user = cc.id_user"
to decide that "sp_connected_test(ul.id_user)" can be rewritten as
"sp_connected_test(cc.id_user)", but in general this is not safe.
The planner has little idea of what the datatype-specific semantics
of equality are, and none whatsoever what the semantics of your
function are. As a real-world example: IEEE-standard floating
point math considers that +0 and -0 are different bit patterns.
They compare as equal, but it's very easy to come up with user-defined
functions that will yield different results for the two inputs.
So the proposed transformation is definitely unsafe for float8.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-10-06 13:38:38 Re: prefix btree implementation
Previous Message Tom Lane 2005-10-06 13:12:58 Re: fixing LISTEN/NOTIFY