Friday, March 30, 2012

newbie question on indices

Hi all,
When one creates a PF or a FK, does SQL server automatically create the
needed indices for optimum speed, or do I have to create them myself in
order to speed join up.
ThanksSQL Server will create indexes for PK and UQ constraint, as they are needed
to quickly find if you
try to insert a duplicate. The PK index is clustered by default and can be o
verridden. SQL Server
does *not* create index for a FK, and such an index can very much improve fo
r instance join
operations (as joins are often done based on PK-FK relations).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Robert Bravery" <me@.u.com> wrote in message news:e8%23gnSPQGHA.3192@.TK2MSFTNGP09.phx.gbl..
.
> Hi all,
> When one creates a PF or a FK, does SQL server automatically create the
> needed indices for optimum speed, or do I have to create them myself in
> order to speed join up.
> Thanks
>|||Thanks
Robert
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:O1jbIVPQGHA.3848@.TK2MSFTNGP12.phx.gbl...
> SQL Server will create indexes for PK and UQ constraint, as they are
needed to quickly find if you
> try to insert a duplicate. The PK index is clustered by default and can be
overridden. SQL Server
> does *not* create index for a FK, and such an index can very much improve
for instance join
> operations (as joins are often done based on PK-FK relations).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Robert Bravery" <me@.u.com> wrote in message
news:e8%23gnSPQGHA.3192@.TK2MSFTNGP09.phx.gbl...
>sql

No comments:

Post a Comment