Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6545689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:36:58+00:00 2026-05-25T11:36:58+00:00

I can’t find anything discussing the case where there are multiple possible indexes that

  • 0

I can’t find anything discussing the case where there are multiple possible indexes that could be used to backup a FK constraint.

It seems from the test below that at FK creation time the FK gets bound to a specific index and this will always be used to validate the FK constraint irrespective of whether a new better index gets added later.

Can any one point to any resources confirming or denying this?

CREATE TABLE T1(
    T1_Id INT IDENTITY(1,1) PRIMARY KEY CLUSTERED  NOT NULL,
    Filler CHAR(4000) NULL,
) 

INSERT INTO T1 VALUES ('');


CREATE TABLE T2(
    T2_Id INT IDENTITY(1,1) PRIMARY KEY NOT NULL,
    T1_Id INT NOT NULL CONSTRAINT FK REFERENCES T1 (T1_Id), 
    Filler CHAR(4000) NULL,
)

/*Execution Plan uses clustered index - There is no NCI*/ 
INSERT INTO T2 VALUES (1,1) 

ALTER TABLE T1 ADD CONSTRAINT
    UQ_T1 UNIQUE NONCLUSTERED(T1_Id) 

/*Execution Plan still use clustered index even after NCI created*/    
INSERT INTO T2 VALUES (1,1) 

SELECT fk.name,
       ix.name,
       ix.type_desc
FROM sys.foreign_keys fk
JOIN sys.indexes ix ON ix.object_id = fk.referenced_object_id
AND ix.index_id = fk.key_index_id
WHERE fk.name = 'FK'


ALTER TABLE T2 DROP CONSTRAINT FK
ALTER TABLE T2  WITH CHECK ADD  CONSTRAINT FK FOREIGN KEY(T1_Id)
REFERENCES T1 (T1_Id)    

/*Now Execution Plan now uses non clustered index*/    
INSERT INTO T2 VALUES (1,1)    

SELECT fk.name,
       ix.name,
       ix.type_desc
FROM sys.foreign_keys fk
JOIN sys.indexes ix ON ix.object_id = fk.referenced_object_id
AND ix.index_id = fk.key_index_id
WHERE fk.name = 'FK'

DROP TABLE T2
DROP TABLE T1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:36:59+00:00Added an answer on May 25, 2026 at 11:36 am

    Martin, I apologize that this isn’t much of an answer, but since you made me curious as well, I did some digging. The information that I can share is:

    It is unlikely in current versions, including Denali, that an alternative would ever be considered in this situation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can this be done? It seems like this should be possible. In general, I
Can someone explain it succinctly? Can it be used with non-Silverlight clients?
Can somebody help me with this. There is HTML code: <h3> <label> <input type=checkbox
Can someone guide me on a possible solution? I don't want to use /bin/cp
Can I set a maximum fps? Is there any way to limit fps in
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
can anyone tell me if it is possible to convert a dojo charting object
Can anyone help me with an excel formula that groups related rows and creates
Can anyone help me trying to find out why this doesn't work. The brushes
Can somebody point me to a resource that explains how to go about having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.