Generate index on foreign key columns

  • tklimczak

    Old Hand

    Points: 321

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

  • John Mitchell-245523

    SSC Guru

    Points: 148769

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

    John

  • srienstr

    SSCrazy

    Points: 2404

    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.

  • Mike Byrd

    Ten Centuries

    Points: 1303

    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

  • srienstr

    SSCrazy

    Points: 2404

    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.

  • mickael.mottet

    SSC Rookie

    Points: 27

    How can we modify this script to :

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

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

    Thanks

  • akljfhnlaflkj

    SSC Guru

    Points: 76202

    Thanks for the script.

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

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