前言 本节我们开始讲讲这一系列性能比较的终极篇IN VS EXISTS VS JOIN的性能分析,前面系列有人一直在说场景不够,这里我们结合查询索引列.非索引列.查询小表.查询大表来综合分析,简短的内容,深入的理解,Always to review the basics. IN VS EXISTS VS JOIN性能分析 我们继续创建测试表,如下 CREATE SCHEMA [compare] CREATE TABLE t_outer ( id INT NOT NULL PRIMARY KEY,
Join Operations ? SORT-MERGE JOIN – Sorts tables on the join key and then merges them together – Sorts are expensive ? NESTED LOOPS – Retrieves a row from one table and finds the corresponding rows in the other table – Usually best for small numbers
----------------------INNER JOIN--------------------------- 1. 三表联合查询 select XX,XX from a , b , c 笛卡尔积,等同于cross join 2. cross join --列出两边所有组合,也叫笛卡尔集A.Rows * B.Rows select * from Sales S cross join Customers C 3. inner join = join --两边都有的才筛选出来