Re: [PERFORM] select max(id) from aTable is very slow

2004-06-03 Thread Richard Huxton
David Teran wrote: Hi, we have a table with about 6.000.000 rows. There is an index on a column with the name id which is an integer and serves as primary key. When we execute select max(id) from theTable; it takes about 10 seconds. Explain analyze returns: Due to the open-ended nature of PG's

[PERFORM] select max(id) from aTable is very slow

2004-06-03 Thread David Teran
Hi, we have a table with about 6.000.000 rows. There is an index on a column with the name id which is an integer and serves as primary key. When we execute select max(id) from theTable; it takes about 10 seconds. Explain analyze returns: --

Re: [PERFORM] select max(id) from aTable is very slow

2004-02-16 Thread David Teran
Hi Nick, Try using: SELECT id FROM theTable ORDER BY is DESC LIMIT 1; Using COUNT, MAX, MIN and any aggregate function on the table of that size will always result in a sequential scan. There is currently no way around it although there are a few work arounds. See the following for more infor

Re: [PERFORM] select max(id) from aTable is very slow

2004-02-16 Thread Nick Barr
Nick Barr wrote: David Teran wrote: Hi, we have a table with about 6.000.000 rows. There is an index on a column with the name id which is an integer and serves as primary key. When we execute select max(id) from theTable; it takes about 10 seconds. Explain analyze returns: ---

Re: [PERFORM] select max(id) from aTable is very slow

2004-02-16 Thread Nick Barr
David Teran wrote: Hi, we have a table with about 6.000.000 rows. There is an index on a column with the name id which is an integer and serves as primary key. When we execute select max(id) from theTable; it takes about 10 seconds. Explain analyze returns: -