简体   繁体   English

monetdb选择最后n行

[英]monetdb select last n rows

My monetdb table has over 100k rows. 我的monetdb表有超过10万行。 I want to select the last n rows from the table. 我想从表中选择最后n行。 Will it be possible to query only the last n records without scanning the entire table? 是否可以仅查询最后n条记录而不扫描整个表?

for Transact SQL: 对于Transact SQL:

SELECT *
FROM [your_table] AS tbl
ORDER BY 1 DESC
TOP n

or others (SQL Standard): 或其他(SQL标准):

SELECT *
FROM [your_table] AS tbl
ORDER BY 1 DESC
LIMIT n

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. 唯一可靠的方法是使列的时间戳或ID值增加,然后可以进行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. 特别是如果没有删除,MonetDB将注意到此列已排序,并使用此事实快速定位最新行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM