Re: [GENERAL] efficiency of group by 1 order by 1

2006-03-17 Thread Merlin Moncure
On 3/17/06, Tom Lane <[EMAIL PROTECTED]> wrote: > "Merlin Moncure" <[EMAIL PROTECTED]> 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

Re: [GENERAL] efficiency of group by 1 order by 1

2006-03-17 Thread Tom Lane
"Merlin Moncure" <[EMAIL PROTECTED]> 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

Re: [GENERAL] efficiency of group by 1 order by 1

2006-03-17 Thread Merlin Moncure
> I use a similar SQL, e.g.: > select func(x)group by func(x) order by func(x) > but my func is rather expensive. Is func(x) evaluated three times > in the above statement? Would it be evaluated only once if I used > select func(x)group by 1 order by 1 try: select q.v from (select f

[GENERAL] efficiency of group by 1 order by 1

2006-03-17 Thread TJ O'Donnell
>> Is there a way to eliminate the ugly repeated use of >> date_trunc('day',endtime)? >>In this particular case you could say >> >>... GROUP BY 1 ORDER BY 1; I use a similar SQL, e.g.: select func(x)group by func(x) order by func(x) but my func is rather expensive. Is func(x) eval