Cost of max

Поиск
Список
Период
Сортировка
Искать

Cost of max

От:
Stefano Bargioni <bargioni@usc.urbe.it>
Дата:
I build a little test table with columns id serial, a text, b text. Why the cost of max(id) is made as a seq scan, as is for count(id)? This is a problem with very large tables.
IMHO, select max(id) could be done using the index prova_id_key.
Your opinion? TIA. Stefano

mydb=> explain select max(id) from prova;
NOTICE:  QUERY PLAN:

Aggregate  (cost=43.00 rows=1000 width=4)
  ->  Seq Scan on prova  (cost=43.00 rows=1000 width=4)

EXPLAIN
mydb=> explain select count(id) from prova;
NOTICE:  QUERY PLAN:

Aggregate  (cost=43.00 rows=1000 width=4)
  ->  Seq Scan on prova  (cost=43.00 rows=1000 width=4)

--
Dott. Stefano Bargioni
Biblioteca della Pontificia Universita' della Santa Croce - Roma
                  
Personal web page:    
--- "Si apud bibliothecam hortulum habes, nihil deerit"  (Cicerone) ---


FAQ