table of Contents
Optimization problems encountered on to record it, not going in-depth study database optimization
View statement execution efficiency
View the execution plan
Can be used directly display the estimated execution plan view, select statement, you can directly select the execution plan
Statement View
set statistics profile on
set statistics io on
set statistics time on
go
--两个go中间为你执行的sql语句
select * from Product p where exists (select id from JotrinDB.dbo.MarkingCode where PartNumber=p.ProductName and MarkingCode like '100%')
go
set statistics profile off
set statistics io off
set statistics time off
Best not to use in, *
This is what I wrote SQL, there are two bad place
select * from Product where productName in (select PartNumber from JotrinDB.dbo.MarkingCode where MarkingCode like '100%')
- In the process, remember not to use *
- Best not to use in, change exists, and exists in the best kind of id field is indexed
sql statement following the completion of the following changes, what data to write, use exists judge id
select p.Name,p.Data from Product p where exists (select id from JotrinDB.dbo.MarkingCode where PartNumber=p.ProductName and MarkingCode like '100%')