My monetdb table has over 100k rows. I want to select the last n rows from the table. Will it be possible to query only the last n records without scanning the entire table?
SELECT *
FROM [your_table] AS tbl
ORDER BY 1 DESC
TOP n
or others (SQL Standard):
SELECT *
FROM [your_table] AS tbl
ORDER BY 1 DESC
LIMIT n
0
votes
The only reliable way of doing this is by having a column with an increasing time stamp or id value that you can ORDER BY.
Especially if there are no deletes, MonetDB will notice that this column is sorted and use this fact to quickly locate the latest rows.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more