documentdb文档上的_ts是否已建立索引? [英] Is _ts on documentdb document indexed?

查看:33
本文介绍了documentdb文档上的_ts是否已建立索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用基于时间戳的BETWEEN查找为更好的性能查询包含我自己的时间戳(毫秒)是否更好?

Is it better to include my own time-stamp (with milliseconds) for higher performance queries using BETWEEN look-ups based on time-stamp?

我从以前的帖子中了解到,它表示为自1970年以来的秒数.由于它是一个核心元素,我可能会猜测它没有被编入索引.

I understand from previous posts that it is represented as number of seconds since 1970. Since it is a core element I might guess it is not indexed.

推荐答案

_ts在DocumentDB中默认情况下是范围索引和最大精度(-1),除非用户明确重写.因此,您可以对其执行范围查询.

_ts is range-indexed and max precision (-1) by default in DocumentDB, unless overridden explicitly by the user. Therefore you can execute range queries against it.

也就是说,如果您需要更细微的时间戳(以毫秒为单位),则最好使用自己的高精度属性.例如,您可以将时间戳记用作ISO 8601格式的字符串,例如-"2016-08-29T21:48:38.334",并对该属性进行范围索引.这有两个目的-使日期和时间易于阅读,并针对该属性有效地执行范围查询.具有该时间戳记属性(例如,称为"createdTs")的示例查询将为:

That said, if you need a more granular timestamp with milliseconds, it is best to use your own higher-precision attribute. For example, you could use a timestamp as a string in the ISO 8601 format, for example - "2016-08-29T21:48:38.334", and range-index that attribute. That will serve two purposes - enable the date and time to be human readable, and execute range queries efficiently against that attribute. An example query with this timestamp attribute (named as, say, "createdTs") would then be:

SELECT r.id FROM root r WHERE 
r.createdTs > "2016-08-29T21:48:38.334" and r.createdTs < "2016-08-29T21:50:00.000"

这篇关于documentdb文档上的_ts是否已建立索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆