Re: efficiency of group by 1 order by 1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
Cc: tjo(at)acm(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: efficiency of group by 1 order by 1
Date: 2006-03-17 20:23:37
Message-ID: 9782.1142627017@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Merlin Moncure" <mmoncure(at)gmail(dot)com> writes:
> select f(x) from t where id = 1 order by n;
> can cause f to execute for the entire table even if id is unique.

Really? I'd consider it a bug if so. Compare

select 1/x from t where x > 0

If the presence of zeroes in t can make this throw a zero-divide error,
the database is broken. In my mind the SQL spec is perfectly clear that
WHERE filtering occurs before evaluation of the SELECT targetlist.
(Sorting, however, occurs afterward --- so there are certainly potential
gotchas of this ilk. But the specific example you give is bogus.)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message William Leite Araújo 2006-03-17 20:40:06 Server "deadlock"?
Previous Message Andrew Stewart 2006-03-17 20:05:17 Strange startup error