How to get last 10 rows in a table on a large database?

Поиск
Список
Период
Сортировка
От Alex@Icepick.com (Alex)
Тема How to get last 10 rows in a table on a large database?
Дата
Msg-id 38270488.5980775@smtp.telekabel.nl
обсуждение исходный текст
Ответы Re: [SQL] How to get last 10 rows in a table on a large database?  (Stoyan Genov <genov@digsys.bg>)
Re: [SQL] How to get last 10 rows in a table on a large database?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Hi,

Does anyone have a good idea to get the last 10 rows from a table? I
tried 

SELECT * FROM table ORDER BY datetime DESC LIMIT 10

But my table has over 1 million rows, so this takes forever.. anyone
has a better idea on how to do this? 

Alex
--
Alex van Es, P.O. Box 698, 7300 AR Apeldoorn, The Netherlands.
8 Webcams, doorbell, fridge, barcodescanner.. all connected to the internet.
Check http://www.icepick.com for details.. 
NEW! A Hyperwired cat.. http://www.blackie.com!


В списке pgsql-sql по дате отправления:

Предыдущее
От: Heiko Wilms
Дата:
Сообщение: pg_dump and "archive = none" ??
Следующее
От: Stoyan Genov
Дата:
Сообщение: Re: [SQL] How to get last 10 rows in a table on a large database?