Results 1 to 4 of 4

Thread: Multicolumn index with unique values with or without IsUnique=yes?

  1. #1
    Join Date
    Jan 2005
    Location
    Prague, Czech Republic
    Posts
    29

    Multicolumn index with unique values with or without IsUnique=yes?

    Assuming I have a multicolumn index in a table and the rows in the index are guaranteed to be unique (one of the later columns is the IDENTITY of this table) is it better to create the index with or without ISUNIQUE? The table is often queried and very seldom modified.
    I would think that with the ISUNIQUE=yes the index could be stored more efficiently, but what do I know.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Not sure what you mean 'the index could be stored more efficiently'. For unique index, sql will check values when update those columns. Otherwise, will not check.

  3. #3
    Join Date
    Jan 2005
    Location
    Prague, Czech Republic
    Posts
    29
    I'm talking about the internal structure of the index. For a unique index the m-n tree, hash or whatever MSSQL decides to use may point directly to the individual rows. For a non-unique it has to point to lists of rows with the same value of the indexed columns instead.

  4. #4
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Is the column combination really unique?. If it is then you should mark it unique, it will help optimizer to get better query plans.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •