Re: [SQL] Slow performance on MAX(primary_key)

2002-10-17 Thread Richard Huxton
On Thursday 17 Oct 2002 12:46 am, Keith Gray wrote: > Getting MIN() adn MAX() seems fairly trivial to me. > > When is on an index or more importantly Primary > Key it must be a common SQL. > > Would it be possible in the code to look at > the field in MIN() or MAX() and if it is > indexed use a si

Re: [SQL] Slow performance on MAX(primary_key)

2002-10-16 Thread Charles H. Woloszynski
Keith: I think it would be great to get the optimizer to do something smart on such a simple (and common) query. I am porting an app to Postgresql and I am not looking forward to having to fix all the postgres-ism that seem trivial like this. Postgres gets a bad rap for this kinda simple q

Re: [SQL] Slow performance on MAX(primary_key)

2002-10-16 Thread Keith Gray
Richard Huxton wrote: >>> As of now, Max() doesn't utilizes the indices hence >>>it always do a sequential scan. >>Is this likely to be sorted in 7.2 ? >>Is anyone looking at this? > As I understand, the problem is that the optimisation only applies for simple > cases... Getting MIN() adn

Re: [SQL] Slow performance on MAX(primary_key)

2002-10-15 Thread Richard Huxton
On Tuesday 15 Oct 2002 8:47 am, Keith Gray wrote: > Ludwig Lim wrote: > > As of now, Max() doesn't utilizes the indices hence > > it always do a sequential scan. > > Thanks Ludwig, > > That does help performance, but I was using a "standard" > SQL command wrapped in a VB6 ADO ODBC program. > > I

Re: [SQL] Slow performance on MAX(primary_key)

2002-10-15 Thread Keith Gray
Ludwig Lim wrote: >>I have just been comparing some large table >>performance under 7.1 using the >> >> select max(primary key)from table; >> > > Try using the following as alternative : > > SELECT primary_key > FROM table > ORDER BY primary_key desc > LIMIT 1; > > This shou

Re: [SQL] Slow performance on MAX(primary_key)

2002-10-14 Thread Ludwig Lim
Hi Keith: --- Keith Gray <[EMAIL PROTECTED]> wrote: > Help, > > I have just been comparing some large table > performance > under 7.1 using the > > select max(primary key)from table; > > We are using this for various functions including > sequence. > Try using the following as alter

[SQL] Slow performance on MAX(primary_key)

2002-10-14 Thread Keith Gray
Help, I have just been comparing some large table performance under 7.1 using the select max(primary key)from table; We are using this for various functions including sequence. It is taking 9 seconds to return this from around 1 million records. Shouldn't this be an instantaneous look