Indexing.

  • I know this is a situation based question but on the general though, what columns would be best suitable to have indexes on in dimension and fact tables.I have working to recreate indexes on a Datamart and there are few situation where PK is on the surrogate keys and unique clustered index on the business keys. My approach would be to create a PK drive clustered index on the business key and created nonclustered index on the surrogate keys. Any input would be helpful.

  • Hard to say either way without knowing what the table design(s) is(are). In addition is to know what the queries are.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • peacesells (1/8/2013)


    what columns would be best suitable to have indexes on in dimension and fact tables.

    indexs should include column which are part of

    Where

    order by

    group by

    JOINs ON clause.

    partition by......etc

    and column which are invole in SELECT should be part of INCLUDE of covering index. thats the generic answer of your generic question 😀

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • Personally I put the Primary Key clustered index on the surrogate Key in the Dimension, with a non-clustered index on the Business key.

    Unless the dimension is a Type 1, I would avoid putting a Unique index on the business key as with Type 2 dimensions you will get repeated business key, and therefore need to add an alternative column to maintain the uniqueness.

    The main reason is that Surrogate keys are the glue that bind Fact table to dimension table, and so if you want to enforce RI (which I would recomend) between Fact and Dimension then the Surrogate key needs to be the PK.

    As for clustering, the reason I suggest the Surrogate key as the clustered index is that you are only ever adding to the end of the Index rather than with a business key which you can be inserting data into the middle of the index thus leading to heavier fragmentation of said index.

    That doesnt mean I wouldnt create a Non-clustered index on the business key, which is be the sensible thing to do in order to aid the ETL and Filtering on the reporting side.

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply