From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael Glaesemann <grzm(at)myrealbox(dot)com> |
Cc: | Steve Tucknott <steve(at)retsol(dot)co(dot)uk>, PostGreSQL <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Sequential Scans On Complex Query With UNION - see why this fails |
Date: | 2006-01-12 04:42:18 |
Message-ID: | 1060.1137040938@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Michael Glaesemann <grzm(at)myrealbox(dot)com> writes:
> On Jan 12, 2006, at 12:21 , Tom Lane wrote:
>> I think what's happening is that the parser implicitly parenthesizes
>> like this:
>>
>> from ((a join b on a.x=b.y) join c on b.y=c.z)
> Any idea off hand if the SQL spec has anything to say on the subject?
SQL92 has this BNF:
<from clause> ::= FROM <table reference> [ { <comma> <table reference> }... ]
<table reference> ::=
<table name> [ [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ] ]
| <derived table> [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ]
| <joined table>
<derived table> ::= <table subquery>
<derived column list> ::= <column name list>
<joined table> ::=
<cross join>
| <qualified join>
| <left paren> <joined table> <right paren>
<cross join> ::=
<table reference> CROSS JOIN <table reference>
<qualified join> ::=
<table reference> [ NATURAL ] [ <join type> ] JOIN
<table reference> [ <join specification> ]
<join specification> ::=
<join condition>
| <named columns join>
<join condition> ::= ON <search condition>
<named columns join> ::=
USING <left paren> <join column list> <right paren>
<join type> ::=
INNER
| <outer join type> [ OUTER ]
| UNION
<outer join type> ::=
LEFT
| RIGHT
| FULL
What we're talking about is the <qualified join> production, whose
inputs are <table reference>s, and a <table reference> can be another
<qualified join> with or without surrounding parentheses. So AFAICS
SQL92 specifically allows both of these constructions.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2006-01-12 04:48:30 | Re: Removing duplicate entries |
Previous Message | Michael Glaesemann | 2006-01-12 03:48:27 | Re: Sequential Scans On Complex Query With UNION - see why this fails |