Monday, March 26, 2012

inedex - should I cluster?

Hi, I have the following delema:
I have a table that has the following fields:
companyid
warehouseid
year
month
productid
val1
...
valn
there are 3 companies, 15 warehouse, 4 year history, 12 months, 3000 prodocts.
the primary key is : companyid, warehouseid, year, month, productid
a) At the end of each month new values are recorded on the table.
b) During the month updates are issued to the current month.
c) queries are usualy include:
* company, warehouse, year, month
* company, year, month, product
Question: what is a good clusterd index for this table, what other indexes
should I implement.
Thx,
Juan"jccondor" <jccondor@.discussions.microsoft.com> wrote in message
news:1373BADF-2A63-4D61-853C-C6A9B894DF73@.microsoft.com...
> Hi, I have the following delema:
> I have a table that has the following fields:
> companyid
> warehouseid
> year
> month
> productid
> val1
> ...
> valn
> there are 3 companies, 15 warehouse, 4 year history, 12 months, 3000
> prodocts.
> the primary key is : companyid, warehouseid, year, month, productid
> a) At the end of each month new values are recorded on the table.
> b) During the month updates are issued to the current month.
> c) queries are usualy include:
> * company, warehouse, year, month
> * company, year, month, product
> Question: what is a good clusterd index for this table, what other indexes
> should I implement.
>
The primary key looks like a good clustered index. Since the queries
usually include the four leading PK columns (company, warehouse, year,
month), or the leading column and other PK columns (company, year, month,
product), a clustered PK will be helpful. Of course the updates will
specify the whole key.
For other indexes, look at the workload. You may want a secondary index on
(year,month) or (product).
David
David

No comments:

Post a Comment