Re: query plan and parenthesis

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: pgsql-general(at)postgresql(dot)org, pajout(at)gingerall(dot)cz
Subject: Re: query plan and parenthesis
Date: 2003-06-13 11:23:18
Message-ID: 3EE9B425.B8F1E9BA@rodos.fzk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I have following view definition given by '\d' command: SELECT t1.col1

> FROM ((table1 t1 JOIN table2 t2 ON ((t1.id = t2.id))) JOIN table3 t3
ON
> ((t2.some = t3.some)));
> Is query planner able to optimize order of joining (t1, t2), t3 or
must
> join with order described by parenthesis ? This is very important for
> joining small (50 rows) and huge (5M rows) tables.
>
The postgresql-7.3.2 documentation says:
Finally, a FROM item can be a JOIN clause, which combines two simpler
FROM items.
(Use parentheses if necessary to determine the order of nesting.)
So, I say, anyway if the planner is able to or not, if you know in
advance what order of
nesting is optimal, use parentheses.
On the other hand, after doing a VACUUM, you can always do an EXPLAIN to
see
how the planner will act.
Regards, Christoph

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Gehrke 2003-06-13 11:33:08 Insert NULL for ''
Previous Message Jean-Michel POURE 2003-06-13 11:22:05 Re: graphical sql-query builder