JOINS, EXISTS or IN which is better? Few questions on SQL

前端 未结 8 1789
不思量自难忘°
不思量自难忘° 2021-01-14 07:58

I have few questions on SQL..

  1. How to analyze the performance of a query? Any software, inbuilt features of MSSQL server 2005/2008?

  2. What shou

8条回答
  •  说谎
    说谎 (楼主)
    2021-01-14 09:02

    MSSQL generally comes with a built in gui tool called Query Analyser which describes how the query will be executed.

    For 2) you could rewrite as:

    SELECT * 
    FROM enquiry_courses ec 
    WHERE EXISTS (select 1 FROM enquiries e 
                  WHERE e.enquiry_id = ec.enquiry_id 
                  and e.session_id ='4cd3420a16dbd61c6af58f6199ac00f1' )
    

    but I can't believe it would make any performance difference in a modern RDBMS.

提交回复
热议问题