Re: foreign key references only part of composite PK - table scan issue
- From: Dave <djohannsen2@xxxxxxxxx>
- Date: Sun, 9 Aug 2009 16:24:55 -0700 (PDT)
On Aug 9, 2:31 pm, Erland Sommarskog <esq...@xxxxxxxxxxxxx> wrote:
Dave (djohanns...@xxxxxxxxx) writes:
thanks for your efforts, you may have a miscommunication though.
there is only 1 join with 3 tables at play, where an index scan
(essentially a table scan) is at play. i won't explain the table
layouts again though - so no worries. thanks again.
Well, given the minimum of information you disclose, there are
certainly good oppurtunies to leaving things up to our imagination,
or miscommunicaiton, if you prefer.
But it's your call. The less you share with us, the less accurate
the advice.
--
Erland Sommarskog, SQL Server MVP, esq...@xxxxxxxxxxxxx
Links for SQL Server Books Online:
SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005:http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000:http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
ok here you go, lots of details. i don't have access to
ABC_Staging.dbo.Stage_ABC_ContactKey until tomorrow but i can recall
it only had one index on it, its PK on NSO_IndividualID, and C.NSO_ID.
you can see the offending tables ABC_Person and ABC_Organization each
only have 1/2 of the fields of the Stage_ABC_ContactKey PK.
SELECT DISTINCT
B.ABC_PersonID,
C.ABC_OrganizationID,
GETDATE() AS ABC_UploadedDate,
NULL AS ABC_ChangeDate,
1 AS IsActive
FROM ABC_Staging.dbo.Stage_ABC_ContactKey AS A WITH (NOLOCK)
JOIN dbo.ABC_Person AS B WITH (NOLOCK)
ON A.NSO_IndividualID = B.NSO_IndividualID
JOIN dbo.ABC_Organization AS C WITH (NOLOCK)
ON C.NSO_ID = A.NSO_ID;
/****** Object: Table [dbo].[ABC_Organization] Script Date:
08/09/2009 16:09:33 ******/
CREATE TABLE [dbo].[ABC_Organization](
[ABC_OrganizationID] [int] IDENTITY(1,1) NOT NULL,
[NSO_SuppressionID] [tinyint] NOT NULL,
[DEF_TOH] [int] NULL,
[DEF_CompositeID] [int] NULL,
[DEF_OrgName] [nvarchar](256) NULL,
[NSO_ID] [int] NULL,
[NSO_Org_Updated] [datetime] NOT NULL,
[TPID] [int] NULL,
[IsActive] [bit] NOT NULL,
[SBL_AccountParentID] [nvarchar](15) NULL,
[NSS_TopParentName] [nvarchar](60) NULL,
[DepthBreadthCustomer] [nvarchar](20) NULL,
[ABC_ChangeDate] [datetime] NULL,
[ABC_DeactivationID] [int] NULL,
[HighestLP] [nvarchar](50) NULL,
CONSTRAINT [ABC_Organization_PK_ABC_OrganizationID] PRIMARY KEY
CLUSTERED
(
[ABC_OrganizationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Index [Idx_ABC_Organization_NSO_ID] Script Date:
08/09/2009 16:17:05 ******/
CREATE NONCLUSTERED INDEX [Idx_ABC_Organization_NSO_ID] ON [dbo].
[ABC_Organization]
(
[NSO_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB
= OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Table [dbo].[ABC_Person] Script Date: 08/09/2009
16:09:56 ******/
CREATE TABLE [dbo].[ABC_Person](
[NSO_Ind_Suppression] [tinyint] NOT NULL,
[ABC_PersonID] [int] IDENTITY(1,1) NOT NULL,
[NSO_IndividualID] [int] NOT NULL,
[NSO_UpdatedDate] [datetime] NOT NULL,
[IsActive] [bit] NOT NULL,
[ABC_ChangeDate] [datetime] NULL,
[ABC_DeactivationID] [int] NULL,
CONSTRAINT [ABC_Person_PK] PRIMARY KEY CLUSTERED
(
[ABC_PersonID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Index [Idx_ABC_Person_NSO_IndividualID] Script
Date: 08/09/2009 16:17:47 ******/
CREATE NONCLUSTERED INDEX [Idx_ABC_Person_NSO_IndividualID] ON [dbo].
[ABC_Person]
(
[NSO_IndividualID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB
= OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
.
- Follow-Ups:
- Re: foreign key references only part of composite PK - table scan issue
- From: Erland Sommarskog
- Re: foreign key references only part of composite PK - table scan issue
- References:
- foreign key references only part of composite PK - table scan issue
- From: Dave
- Re: foreign key references only part of composite PK - table scan issue
- From: Erland Sommarskog
- Re: foreign key references only part of composite PK - table scan issue
- From: Dave
- Re: foreign key references only part of composite PK - table scan issue
- From: Erland Sommarskog
- Re: foreign key references only part of composite PK - table scan issue
- From: Dave
- Re: foreign key references only part of composite PK - table scan issue
- From: Erland Sommarskog
- foreign key references only part of composite PK - table scan issue
- Prev by Date: Re: foreign key references only part of composite PK - table scan issue
- Next by Date: Server Latency Test
- Previous by thread: Re: foreign key references only part of composite PK - table scan issue
- Next by thread: Re: foreign key references only part of composite PK - table scan issue
- Index(es):
Relevant Pages
|