From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Philip Warner <pjw(at)rhyme(dot)com(dot)au> |
Cc: | Don Baccus <dhogaza(at)pacifier(dot)com>, Chris Bitmead <chris(at)bitmead(dot)com>, pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace |
Date: | 2000-01-25 06:12:46 |
Message-ID: | 12269.948780766@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
Philip Warner <pjw(at)rhyme(dot)com(dot)au> writes:
>>> SQL in general doesn't believe that tuple ordering has any semantic
>>> significance --- you can ask for ORDER BY, but that's only honored
>>> at the end stage of SELECT result delivery, not necessarily anywhere
>>> in the bowels of a query.
> Out of curiosity, does the SQL spec give any rules or guidelines about when
> aggregates should be applied to resultant rows? Or is it one of the
> implementation-dependant things?
Well, SQL's conceptual model is perfectly clear about the processing
work flow of a SELECT: after you've constructed the tuple set (which
might involve joining multiple relations), you apply the WHERE condition
to filter out uninteresting tuples. Then you apply GROUP BY (if given)
to divvy the tuples into groups. Then you apply HAVING to eliminate
uninteresting groups. Then you apply aggregate functions (if any) to
individual groups, or to the whole filtered result set if no groups.
Finally you apply ORDER BY to whatever's left.
Note that at no point except the final output is there any notion
of the tuples being generated or processed in a particular order.
Given appropriate hardware, much of this could be done in parallel.
Parallel or not, an implementation is free to choose the processing
order for its convenience.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | The Hermit Hacker | 2000-01-25 06:39:53 | Re: [HACKERS] Happy column dropping |
Previous Message | Chris Bitmead | 2000-01-25 06:07:03 | Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Meskes | 2000-01-25 07:12:36 | Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace |
Previous Message | Chris Bitmead | 2000-01-25 06:07:03 | Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace |