Tuesday, January 28, 2014

Split date range without Calendar table

Judging from your description and query plan, you are selecting a very small fraction of your big table.


In that case, it can be beneficial to implement a Relational Interval Tree. You can find an SQL Server implementation in the article Date Range Scans. This technique allows you to avoid full index scans.


The article has an example with a precision of 1 day and an example with a precision of 1 second. You could try the 1 second precision example immediately.


If you are working with 15 minute intervals, then you could tailor it to anywhere between 1 and 10 minutes precision, because that would probably be sufficient for your solution, and allow a bigger domain for the calendar part then the 1 second precision in the article, or with a smaller domain may allow you to restrict the "node" data type to a smaller integer type.




Gert-Jan


No comments:

Post a Comment