と呼ばれる2つのテーブル"Users(60,0000 records),UserBasicInfo(60,0000 records)"
があります.Usersテーブルには、UsersID列にクラスター化されたインデックスがあります.UserBasicInfoテーブルには、UsersID FKポイントがUsersテーブルUsersID列を指し、列に非クラスター化がありUpdateTime,UsersID
ます.
CREATE TABLE [dbo].[Users](
[UsersID] [int] IDENTITY(100000,1) NOT NULL,
[LoginUsersName] [nvarchar](50) NOT NULL,
[LoginUsersPwd] [nvarchar](50) NOT NULL,
[Email] [nvarchar](80) NOT NULL,
[IsEnable] [int] NOT NULL,
[CreateTime] [datetime] NOT NULL,
[LastLoginTime] [datetime] NOT NULL,
[LastLoginIp] [nvarchar](50) NOT NULL,
[UpdateTime] [datetime] NOT NULL,
CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED
(
[UsersID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[UserBasicInfo](
[UserBaicInfoID] [int] IDENTITY(1,1) NOT NULL,
[UsersID] [int] NOT NULL,
[ResumePoints] [nvarchar](50) NOT NULL,
[IsChineseOrEnglish] [int] NOT NULL,
[UserName] [nvarchar](50) NOT NULL,
[Sex] [int] NOT NULL,
[Height] [int] NOT NULL,
[Birthday] [datetime] NOT NULL,
[Age] [int] NOT NULL,
[IDCard] [nvarchar](50) NOT NULL,
[IsMarryed] [int] NOT NULL,
[NativePlace] [nvarchar](50) NOT NULL,
[PoliticalStatus] [int] NOT NULL,
[CurrentAddress] [nvarchar](50) NOT NULL,
[CurrentAddressDetail] [nvarchar](50) NOT NULL,
[WorkExperience] [int] NOT NULL,
[HighestEducation] [int] NOT NULL,
[LogoPath] [nvarchar](200) NULL,
[MobilePhone] [nvarchar](50) NOT NULL,
[Phone] [nvarchar](50) NULL,
[QQ] [nvarchar](50) NULL,
[Blog] [nvarchar](300) NULL,
[MicroBlog] [nvarchar](300) NULL,
[PositionDesired] [nvarchar](100) NOT NULL,
[IndustrySmallClass] [nvarchar](100) NULL,
[PositionName] [nvarchar](100) NOT NULL,
[PositionType] [int] NOT NULL,
[WorkAddressLarge] [int] NOT NULL,
[WorkAddressSmall] [nvarchar](200) NOT NULL,
[WorkAddressSmallText] [nvarchar](100) NOT NULL,
[Salary] [int] NOT NULL,
[HousingRequirement] [int] NOT NULL,
[ToWorkTime] [int] NOT NULL,
[ResumeState] [int] NOT NULL,
[IsSystemAdd] [int] NOT NULL,
[CreateTime] [datetime] NOT NULL,
[UpdateTime] [datetime] NOT NULL,
[RefreshDateTime] [datetime] NOT NULL,
[RefreshTime] [int] NOT NULL,
[TotalTime] [int] NOT NULL,
CONSTRAINT [PK_UserBasicInfo] PRIMARY KEY CLUSTERED
(
[UserBaicInfoID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
ALTER TABLE [dbo].[UserBasicInfo] WITH CHECK ADD CONSTRAINT [FK_UserBasicInfo_Users] FOREIGN KEY([UsersID])
REFERENCES [dbo].[Users] ([UsersID])
ただし、低速で実行します。
DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE
SELECT TOP 100 * FROM Users U INNER JOIN UserBasicInfo UB ON UB.UsersID=U.UsersID ORDER BY UB.UpdateTime DESC
SQL Server Execution Times:
CPU time = 16 ms, elapsed time = 3568 ms.
次に、以下を高速に実行します。
SELECT TOP 100 * FROM Users U INNER JOIN UserBasicInfo UB ON UB.UsersID=U.UsersID ORDER BY UB.UpdateTime DESC
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 163 ms.
正常ですか?