Generate index on foreign key columns

  • Comments posted to this topic are about the item Generate index on foreign key columns

  • Does this work where the foreign key constraint consists of more than one column?

    John

  • Which version of SQL Server is this written for? I've got 2000, and neither the table names nor column names match the system tables.


    Puto me cogitare, ergo puto me esse.
    I think that I think, therefore I think that I am.

  • There are times when an index is not needed for a foreign key. If the table is small (low number of rows) or the index column has little selectivity, then why add the overhead of an index? I wrote a similar script about a month ago, but found that the were many times the index just wasn't needed.

    Mike Byrd

  • Mike Byrd (3/4/2008)


    There are times when an index is not needed for a foreign key. If the table is small (low number of rows) or the index column has little selectivity, then why add the overhead of an index? I wrote a similar script about a month ago, but found that the were many times the index just wasn't needed.

    It can be run as just a select first to pull up a list for evaluation. A starting point like that can be useful when you're trying to tune an inherited database.


    Puto me cogitare, ergo puto me esse.
    I think that I think, therefore I think that I am.

  • How can we modify this script to :

    - Rename all PK indexes to "IX_[TableName];

    - Rename all FK indexes to "IX_[TableName]_[ColumnName]";

    Thanks

  • Thanks for the script.

Viewing 7 posts - 1 through 6 (of 6 total)

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