Does denormalizing rows to columns enhance performance in SQL Server? -
i have data matrix of integer values indicate banded distribution curve. i'm optimizing select performance on insert performance. there max 100 bands. i'll querying data summing or averaging bands across period of time.
my question can achieve better performance flattening data across table 1 column each band, or using single column representing band value?
flattened data
userid activityid datevalue band1 band2 band3....band100 10001 10002 1/1/2013 1 5 100 200
or normalized
userid activityid datevalue band bandvalue 10001 10002 1/1/2013 1 1 10001 10002 1/1/2013 2 5 10001 10002 1/1/2013 3 100
sample query
select avg(band1), avg(band2), avg(band3)...avg(band100) activitybands group userid datevalue > '1/1/2012' , datevalue < '1/1/2013'
store data in normalized format.
if not getting acceptable performance scheme, instead of denormalizing, first consider indexes have on table. you're missing index make perform similar denormalized table. next, try writing query retrieve data normalized table result set looks denormalized table, , use query create indexed view. give select performance identical denormalized table, retain nice data organization benefits of proper normalization.
Comments
Post a Comment