Inner join vs Where

后端 未结 19 1284
庸人自扰
庸人自扰 2020-11-22 05:20

Is there a difference in performance (in oracle) between

Select * from Table1 T1 
Inner Join Table2 T2 On T1.ID = T2.ID

And



        
19条回答
  •  长发绾君心
    2020-11-22 06:12

    No! The same execution plan, look at these two tables:

    CREATE TABLE table1 (
      id INT,
      name VARCHAR(20)
    );
    
    CREATE TABLE table2 (
      id INT,
      name VARCHAR(20)
    );
    

    The execution plan for the query using the inner join:

    -- with inner join
    
    EXPLAIN PLAN FOR
    SELECT * FROM table1 t1
    INNER JOIN table2 t2 ON t1.id = t2.id;
    
    SELECT *
    FROM TABLE (DBMS_XPLAN.DISPLAY);
    
    -- 0 select statement
    -- 1 hash join (access("T1"."ID"="T2"."ID"))
    -- 2 table access full table1
    -- 3 table access full table2
    

    And the execution plan for the query using a WHERE clause.

    -- with where clause
    
    EXPLAIN PLAN FOR
    SELECT * FROM table1 t1, table2 t2
    WHERE t1.id = t2.id;
    
    SELECT *
    FROM TABLE (DBMS_XPLAN.DISPLAY);
    
    -- 0 select statement
    -- 1 hash join (access("T1"."ID"="T2"."ID"))
    -- 2 table access full table1
    -- 3 table access full table2
    

提交回复
热议问题