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

From: Alex(at)Icepick(dot)com (Alex)
To: pgsql-sql(at)postgresql(dot)org
Subject: How to get last 10 rows in a table on a large database?
Date: 1999-11-06 10:37:17
Message-ID: 38270488.5980775@smtp.telekabel.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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!

Browse pgsql-sql by date

  From Date Subject
Next Message Stoyan Genov 1999-11-06 11:36:47 Re: [SQL] How to get last 10 rows in a table on a large database?
Previous Message Heiko Wilms 1999-11-06 10:28:30 pg_dump and "archive = none" ??