两个SQL查询的性能差异

时间:2013-09-07 22:45:40

标签: sql oracle

这是两个视图的简化版本:

viewA is select * from myTable;
viewB is select * from viewA;

直接从viewA中选择和从viewB中选择是否有任何性能差异,因为从viewB中选择另一个是viewA的图层?

1 个答案:

答案 0 :(得分:3)

CREATE OR REPLACE FORCE VIEW  "VIEWA" ("TITLE", "VALUE1", "VALUE2", "ID") AS 
  select "TITLE","VALUE1","VALUE2","ID" from dati
/
​CREATE OR REPLACE FORCE VIEW  "VIEWB" ("TITLE", "VALUE1", "VALUE2", "ID") AS 
  select "TITLE","VALUE1","VALUE2","ID" from viewa
/

解释select * from viewA的计划

Operation           Options         Object  Rows    Time    Cost    Bytes   Filter          Access
                                                                            Predicates *    Predicates
SELECT STATEMENT                            4       1       3       268      
TABLE ACCESS        STORAGE FULL    DATI    4       1       3       268      

解释select * from viewB的计划

Operation           Options         Object  Rows    Time    Cost    Bytes   Filter          Access
                                                                            Predicates *    Predicates
SELECT STATEMENT                            4       1       3       268      
TABLE ACCESS        STORAGE FULL    DATI    4       1       3       268

我的答案必须是:不,没有任何性能差异。