I have pasted 2 explain plans here for the queries doing the same thing. For the 1st query which is using EXISTS consistent gets is too high 151438 but the cost is low 4.
In the 2nd query with the flat structure the cost is high 29 but the consistent gets is low 109. So my question is which query is better one with the cost or one with the consistent gets. If the consistent gets is high what does that mean ?
thanks
SQL> SELECT Res_Name, Res_ID
2 FROM mwebRes
3 WHERE EXISTS(Select 1 from mwebExpense , MWEBWORK
4 where Expense_Entity_Type IN (1,4) AND Res_ID =Expense_Client_ID
5 AND Work_Par6=1117 AND Expense_Task_ID =Work_ID)
6 ORDER BY Res_Name ;
no rows selected
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=83 Bytes=1494
)
1 0 SORT (ORDER BY) (Cost=4 Card=83 Bytes=1494)
2 1 FILTER
3 2 INDEX (FAST FULL SCAN) OF 'IX_RES_ENTITY' (NON-UNIQUE)
(Cost=2 Card=83 Bytes=1494)
4 2 NESTED LOOPS (Cost=22 Card=5 Bytes=70)
5 4 INDEX (RANGE SCAN) OF 'IX_WORK_PAR6' (NON-UNIQUE) (C
ost=2 Card=4 Bytes=24)
6 4 TABLE ACCESS (BY INDEX ROWID) OF 'MWEBEXPENSE' (Cost
=5 Card=63 Bytes=504)
7 6 INDEX (RANGE SCAN) OF 'IX_EXPENSE_TASK' (NON-UNIQU
E) (Cost=1 Card=63)
Statistics
----------------------------------------------------------
0 recursive calls
4 db block gets
151438 consistent gets
0 physical reads
0 redo size
507 bytes sent via SQL*Net to client
739 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
0 rows processed
SQL>
SQL> SELECT Res_Name, Res_ID FROM mwebRes
2 WHERE Res_ID in(Select distinct Expense_Client_ID from mwebExpense
3 where Expense_Entity_Type IN (1,4)
4 AND Expense_Task_ID in(SELECT Work_ID from mwebwork where Work_Par6=1117))
5 ORDER BY Res_Name ;
no rows selected
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=29 Card=54 Bytes=167
4)
1 0 SORT (ORDER BY) (Cost=29 Card=54 Bytes=1674)
2 1 HASH JOIN (Cost=28 Card=54 Bytes=1674)
3 2 VIEW OF 'VW_NSO_1' (Cost=24 Card=54 Bytes=702)
4 3 SORT (UNIQUE) (Cost=24 Card=54 Bytes=756)
5 4 NESTED LOOPS (Cost=22 Card=95 Bytes=1330)
6 5 INDEX (RANGE SCAN) OF 'IX_WORK_PAR6' (NON-UNIQUE
) (Cost=2 Card=4 Bytes=24)
7 5 TABLE ACCESS (BY INDEX ROWID) OF 'MWEBEXPENSE' (
Cost=5 Card=3393 Bytes=27144)
8 7 INDEX (RANGE SCAN) OF 'IX_EXPENSE_TASK' (NON-U
NIQUE) (Cost=1 Card=3393)
9 2 INDEX (FAST FULL SCAN) OF 'IX_RES_ENTITY' (NON-UNIQUE)
(Cost=2 Card=1646 Bytes=29628)
Statistics
----------------------------------------------------------
0 recursive calls
4 db block gets
102 consistent gets
0 physical reads
0 redo size
507 bytes sent via SQL*Net to client
745 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
3 sorts (memory)
0 sorts (disk)
0 rows processed
SQL>
