Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 is relation ship make data search fast

Author  Topic 

indersshekhawat
Starting Member

26 Posts

Posted - 2008-03-29 : 03:39:25
sir,
i have two option


1. my primary table and second table are join in a query. but i not set primary key and forign key realtion ship
2. i set the realtion ship and then do the query

which option is fast for searching data

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-03-29 : 11:23:14
Adding foreign keys does not help with performance, but adding an index on those same columns does.

When you add a primary key to a table, you automatically get an index with it. But SQL Server does not automatically add indexes to foreign keys, so we must add those manually. All foreign keys should have a respective index created.


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2008-03-29 : 14:36:46
An index on the referenced column(s) in the secondary table will probably help. Make it a unique index if it is unique.
Whether this should be clustered or not or include other columns depends on your system.
An index on the primary table column(s) may help but again depends on your system.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -