Azure DocumentDb“高水印"/时间戳 [英] Azure DocumentDb "high water mark"/timestamp
问题描述
我正在寻求实现一个过程,该过程偶尔会从DocumentDb中提取所有新"记录,其中新"是自上次运行该过程以来添加或修改的所有文档."
I'm looking to implement a process that will occasionally pull all "new" records from a DocumentDb, where new is "all documents added or modified since the last time the process was run."
SQL Server为此提供了rowversion,可以保证它是唯一的,并且在数据库的所有行和列中都单调增加.
SQL Server has rowversion for this, which is guaranteed unique and monotonically increasing across all rows and columns in a database.
我看到DocumentDb具有_ts,(根据文档)该_ts被用作Azure搜索索引的高水位标记,但是它如何工作?如果在读取时同时插入多个文档,则它们可能都具有相同的_ts值.在下一次读取时,如果与_ts的比较严格大于,则将丢失某些文档;否则,将丢失某些文档.如果大于或等于,则会再次拉出某些文档.
I see DocumentDb has _ts, which (according to the documentation) used as a high water mark for Azure Search indexing, but how does that work? If multiple documents are inserted at the same time as a read takes place, it's possible that all of them have the same _ts value. On the next read, if the comparison against _ts is strictly greater than, then some documents will be missed; if it's greater-than-or-equals, some documents will be pulled a second time.
为此可以安全使用_ts吗?
Is _ts safe to use for this?
推荐答案
_ts
属性特定于文档,而不是文档集合.它表示特定文档的更新时间(自1970年1月1日起,以秒为单位).
The _ts
property is specific to a document, not a collection of documents. It represents the time that a particular document was updated (in seconds, since Jan 1 1970).
_ts
属性不会为集合中的所有文档提供较高的水印.每个文档都有其自己独立的_ts
属性(该属性可能与另一个文档的_ts
属性具有相同的值).
The _ts
property will not give you a high water mark across all documents in a collection. Each document has its own independent _ts
property (which may have the same value as another document's _ts
property).
有关更多详细信息,请参见此答案.
See this answer for a bit more detail.
这篇关于Azure DocumentDb“高水印"/时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!