From: Tom Lane <tgl@sss.pgh.pa.us>
To: Philip Warner <pjw@rhyme.com.au>
Cc: Don Baccus <dhogaza@pacifier.com>
Cc: Chris Bitmead <chris@bitmead.com>
Cc: pgsql-hackers@postgreSQL.org
Subject: Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace
Date: Tue, 25 Jan 2000 01:12:46 -0500
Message-ID: <12269.948780766@sss.pgh.pa.us> (raw)
In-Reply-To: <3.0.5.32.20000125170026.0357d8f0@mail.rhyme.com.au>
References: <11879.948776470@sss.pgh.pa.us>
<3.0.5.32.20000125150557.036121c0@mail.rhyme.com.au>
<2295.948765015@sss.pgh.pa.us>
<3.0.5.32.20000125140349.035768d0@mail.rhyme.com.au>
<3.0.5.32.20000125150557.036121c0@mail.rhyme.com.au>
<3.0.5.32.20000125170026.0357d8f0@mail.rhyme.com.au>
Philip Warner <pjw@rhyme.com.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, pjw@rhyme.com.au, dhogaza@pacifier.com, chris@bitmead.com, pgsql-hackers@postgreSQL.org
Subject: Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace
In-Reply-To: <12269.948780766@sss.pgh.pa.us>
References: <11879.948776470@sss.pgh.pa.us> <3.0.5.32.20000125150557.036121c0@mail.rhyme.com.au> <2295.948765015@sss.pgh.pa.us> <3.0.5.32.20000125140349.035768d0@mail.rhyme.com.au> <3.0.5.32.20000125170026.0357d8f0@mail.rhyme.com.au> <12269.948780766@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox