Hangfire icon indicating copy to clipboard operation
Hangfire copied to clipboard

Idea to improve Sql server query performance with timestamp column

Open victorcassel opened this issue 3 years ago • 2 comments

A timestamp column is an automatically increased value (db) globally unique binary value, on every row update, maintained by the SQL Server engine. Since the timestamp column can be indexed it could potentially allow much faster querying for queries of the type "give me changed rows since last check", by adding a where condition in tsql pseudocode style WHERE row.timestamp.ToBinary() > @LASTCHECKED Is it worth investigating with performance testing of some large datasets ?

victorcassel avatar Jan 31 '22 15:01 victorcassel

Victor, could you tell me what table and query are talking about?

odinserj avatar Jan 31 '22 15:01 odinserj

I just assumed the database querying was a bit of a bottleneck seeing your poll default to 15 secs. I haven't had time to check which queries would benefit the most. Guessing that any periodic hotspot queries checking checking for updates could rely on on initial super quick query just to check the top(timestamp) value to lookup if table has been touched at all since a cached @lastChangedTimestamp. That way you wouldn't need to issue the full query every n:th second.

victorcassel avatar Feb 02 '22 08:02 victorcassel