I would like to make queries on fact table in star schema.
I need to capture lot of values like gross sales net sales regional sales etc for combination of other couple values that is PK.
I have two options:
- One row with PK and lot of columns with measures like gross sales, regional sales etc.
- make measures as a dimension, so PK would be bigger – there would be added column Measures in row. And only one value beside PK. So I decompose the one row with many Measures to lot of rows with one Measure.
What is better for performance, both insert and select?
You will have contention issues if you have a single row with all the values, assuming you have simultaneous inserts/updates and reads.
Having a single wide table also means it’s much more difficult to add new measures in the future – it requires changing the table schema which will lock the table and cause other problems.
Your
SELECTperformance should be similar, unless you are pulling multiple values for the same PK in the same query, in which case the wider table would probably be a little quicker.