[英]sqlite select by date C#
Is this the preferred/fastest way to select values after a certain date from a database: 这是从数据库中选择某个日期之后的值的首选/最快方法:
SELECT name, creationDate FROM sometable WHERE date(creationDate) >= date('_date_in_sqlite_format_')
where creationDate
is DATETIME DEFAULT CURRENT_TIMESTAMP
type and _date_in_sqlite_format_
is '2007-01-01 10:00:00'
for example. 例如,其中
creationDate
是DATETIME DEFAULT CURRENT_TIMESTAMP
类型,而_date_in_sqlite_format_
是'2007-01-01 10:00:00'
。
Is there a better way that can help sqlite engine process data faster? 有没有更好的方法可以帮助sqlite引擎更快地处理数据?
The question is theoretical. 这个问题是理论上的。 I am aware that the query is not parameterized and/or follows more optimized programming conventions.
我知道查询没有参数化和/或遵循更优化的编程约定。
The date()
function returns a value in the format yyyy-mm-dd
. date()
函数以yyyy-mm-dd
格式返回值。 If you compare against a value that has the same format as the column values, you can make the comparison directly, which would allow optimization by using an index: 如果与具有与列值相同格式的值进行比较,则可以直接进行比较,这将允许通过使用索引进行优化:
... WHERE creationDate >= '2008-01-01 00:00:00'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.