I have never partitioned a table, however from what I have read it has many advantage in terms of querying and archiving data.
Is it superior to creating indexes? Are there any disadvantages? Is the time spent on partitioning the only cost?
There are two reasons to partition a table - if its very large or if you need to quickly add or drop off a slice of data.
On a vary large audit table you may find it useful to divide the table into monthly partitions. This way when you search for rows for a given month SQL Server only has to look through the partition associated with that month. When doing selects you can treat the partitioned as a typical table - no special syntax is necessary.
If at the beginning of a new month you may want to drop the oldest month of data and add the newest month it is then a simple operation to drop a partition and add a partition. SQL Server does not have to rebuild the indexes on the entire table - it just drops and adds the partition(s) internally as a meta operation and usually takes seconds.
The SQL to do so is not hard and you can arrange to backup individual partitions. But partitioning in SQL Server is only available on Enterprise Edition and partitioned tables cannot be restored to other versions of SQL Server.
Background:
Latency of your database query will be low if most of the operations happen in memory. Databases go to great lengths to do this automatically. They also offer tuning options to make sure your buffer cache/ buffer pool and other options can be set correctly.
Why partition the table?
As we keep adding rows to the table, size of primary key index and any other indexes on the table also grows. Once they grow to a point where the entire index does not fit in the configured size of buffer (place where it stores pages that are frequently accessed), the database engine will have to go and fetch index pages from disk and thus slowing down the query.
Its not superior or inferior to indexes, its a different technique.
Before going the partitioning route
Advantages of partitioning
Disadvantages
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With