'Table Partitioning advice
I'm trying to take advantage of partitioning on a massive table, both for query improvement as well as archiving.
There are multiple tables using the same formatting but just as an example:
Create Table Example(
id int,
transactiondate date,
transactiontimestamp datetime2(7)
--Lots of other columns here)
On insert into these tables, transactiondate is extracted from transactiontimestamp.
Vb.Net example
StoredProcedure.Parameters.Add("@TransactionDate", SqlDbType.DateTime)
StoredProcedure.Parameters("@TransactionDate").Value = New DateTime(Transaction.TransactionDate.Year, Transaction.TransactionDate.Month, Transaction.TransactionDate.Day)
StoredProcedure.Parameters.Add("@TransactionTimeStamp", SqlDbType.DateTime2)
StoredProcedure.Parameters("@TransactionTimeStamp").Value = Transaction.TransactionDate
I'm not able to alter the insert transactions as the above code is boiler plated all over the place in different interfaces.
My issue is that a significant number of querys are done on both the TransactionTimeStamp (for OLTP purposes) and TransactionDate for reporting purposes.
Partitioning on TransactionDate makes sense as we'll be archiving based on it, as well as helping reporting out. However it does nothing for the processing transactions which rarely join on to TransactionDate...
Any advice welcome on how I could better utilise these tables. "I'm trying to get into a position where I can easily archive large chunks of data, which I was hoping to do via date partitioning. I'm also hoping to obtain the benefit of partition exclusion for queries hitting these tables."
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
