当前位置: 代码迷 >> Sql Server >> SQL语句执行计划求解惑,该怎么解决
  详细解决方案

SQL语句执行计划求解惑,该怎么解决

热度:85   发布时间:2016-04-27 13:32:45.0
SQL语句执行计划求解惑
 

执行这条SQL的 时候会innerjoin循环呢 我的建表语句是这样的USE [yc_hw_ems]
GO
/****** 对象: Table [dbo].[t_ems_organization] 脚本日期: 02/04/2012 15:20:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[t_ems_organization](
[id] [varchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
[dep_name] [varchar](255) COLLATE Chinese_PRC_CI_AS NULL,
[dep_no] [varchar](255) COLLATE Chinese_PRC_CI_AS NULL,
[remarks] [text] COLLATE Chinese_PRC_CI_AS NULL,
[create_id] [varchar](255) COLLATE Chinese_PRC_CI_AS NULL,
[create_date] [datetime] NULL,
[update_id] [varchar](255) COLLATE Chinese_PRC_CI_AS NULL,
[update_date] [datetime] NULL,
[delete_id] [varchar](255) COLLATE Chinese_PRC_CI_AS NULL,
[delete_date] [datetime] NULL,
[parent_id] [varchar](255) COLLATE Chinese_PRC_CI_AS NULL,
[state] [int] NULL,
[indexs] [int] NULL,
[pid] [varchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK__t_ems_organizati__22AA2996] PRIMARY KEY CLUSTERED 
(
[id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
USE [yc_hw_ems]
GO
ALTER TABLE [dbo].[t_ems_organization] WITH CHECK ADD CONSTRAINT [FK81A28892A265B114] FOREIGN KEY([pid])
REFERENCES [dbo].[t_ems_organization] ([id])


------解决方案--------------------
探讨
我觉得应该是非聚集簇索引p_id查找啊 为嘛它又去嵌套循环外键的聚集簇索引呢