Query optimization (select single record and join)

From: "Orest Kozyar" <orest(dot)kozyar(at)gmail(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Query optimization (select single record and join)
Date: 2007-06-29 15:02:47
Message-ID: 005c01c7ba5e$8eaa3500$6e32000a@issphoenix
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have the following sql:

CREATE OR REPLACE FUNCTION foo (in x integer) RETURNS float AS $$
SELECT max(tableB.columnC)
FROM
tableA inner join tableB on (tableA.columnA =
tableB.columnB)
WHERE
tableA.columbA = x
... (additional code to select which of the many "foo" records referencing
the same row in the foreign table is the one we want)

What I am wondering is whether the database first eliminate all rows in
tableA that don't meet the criteria before performing the join, or does it
perform the join first then eliminate all records that don't meet the
criteria?

Thanks,
Orest

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2007-06-29 15:09:20 Re: commit transaction failed
Previous Message andrew quaresma 2007-06-29 14:42:32 db replication