Re: query plan and parenthesis - Mailing list pgsql-general

From Jan Poslusny
Subject Re: query plan and parenthesis
Date
Msg-id 3EE9B886.2060607@gingerall.cz
Whole thread Raw
In response to Re: query plan and parenthesis  (Christoph Haller <ch@rodos.fzk.de>)
List pgsql-general
Thanks for answer, but:
I did not want to determine the order of nesting, so I wrote something
like CREATE VIEW myview AS SELECT ... FROM t1 INNER JOIN t2 ON ... INNER
JOIN t3 ON ... ; - without parenthesis
When I read output of '\d myview', I found parenthesis.
I think I must set some appropriate nesting order when I am defining the
view - optimizer are not able to resolve it from internally stored
definition.

regards, jan

Christoph Haller wrote:
>>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
>
>


pgsql-general by date:

Previous
From: Christoph Haller
Date:
Subject: Re: query plan and parenthesis
Next
From: Martin Marques
Date:
Subject: Re: Postgres performance comments from a MySQL user