我们正在对性能问题进行故障排除-该应用程序使用VIEW并过滤谓词,如下所述。在第一种情况下,结果以秒为单位检索,但是第二种结果运行了一个多小时。 该视图中引用的列实际上指向表D。请注意,此视图是出于其他目的而编写的,现在用于增强功能(不知道为什么-管理决策)。 我可以看到问题是分区表E和F上的FTS,但无法理解谓词的顺序为什么/如何改变执行计划?这只是一种基于成本的方法,统计信息是最新的。 这不是一个格式正确的查询-使用%会消除索引等-但令我感到困惑的是,为什么当语句交换过滤谓词时计划会更改
select COL2 from VIEW where COL3 like '%180%' and COL4 LIKE '%Solu%' Plan hash value: 1618822878 ------------------------------------------------------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | ------------------------------------------------------------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | | | 1379K(100)| | | | PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------ |* 1 | FILTER | | | | | | | | | 2 | NESTED LOOPS OUTER | | 116K| 8568K| 1077K (19)| 02:47:19 | | | |* 3 | HASH JOIN RIGHT OUTER | | 97611 | 6481K| 266K (1)| 00:41:25 | | | |* 4 | INDEX FAST FULL SCAN | IDX1_A | 45156 | 352K| 25 (8)| 00:00:01 | | | | 5 | NESTED LOOPS | | 97611 | 5719K| 266K (1)| 00:41:25 | | | | 6 | NESTED LOOPS | | 98629 | 5719K| 266K (1)| 00:41:25 | | | | 7 | VIEW | VW_NSO_1 | 98629 | 674K| 82 (3)| 00:00:01 | | | | 8 | HASH UNIQUE | | 98629 | 1338K| 82 (3)| 00:00:01 | | | | 9 | UNION-ALL | | | | | | | | | 10 | TABLE ACCESS FULL | B | 97591 | 667K| 80 (3)| 00:00:01 | | | | 11 | TABLE ACCESS FULL | C | 1038 | 2076 | 2 (0)| 00:00:01 | | | PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------ |* 12 | INDEX UNIQUE SCAN | PK_D | 1 | | 2 (0)| 00:00:01 | | | |* 13 | TABLE ACCESS BY GLOBAL INDEX ROWID| D | 1 | 53 | 3 (0)| 00:00:01 | ROWID | ROWID | | 14 | VIEW | | 1 | 7 | 8 (25)| 00:00:01 | | | | 15 | UNION ALL PUSHED PREDICATE | | | | | | | | | 16 | SORT UNIQUE | | 1 | 9 | 4 (25)| 00:00:01 | | | |* 17 | INDEX RANGE SCAN | IDX1_E | 1 | 9 | 3 (0)| 00:00:01 | | | | 18 | SORT UNIQUE | | 1 | 9 | 5 (20)| 00:00:01 | | | |* 19 | INDEX RANGE SCAN | F | 2 | 18 | 4 (0)| 00:00:01 | | | |* 20 | TABLE ACCESS BY INDEX ROWID | G | 1 | 36 | 3 (0)| 00:00:01 | | | |* 21 | INDEX UNIQUE SCAN | UK_G | 1 | | 2 (0)| 00:00:01 | | | ------------------------------------------------------------------------------------------------------------------------------------
select COL2 from VIEW where COL4 LIKE '%Solu%' AND COL3 like '%180%' ; Plan hash value: 2380952204 ----------------------------------------------------------------------------------------------------------------------------------------------------- | Id | Pid | Ord | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop | ----------------------------------------------------------------------------------------------------------------------------------------------------- | 0 | | 24 | SELECT STATEMENT | | | | | 2598K(100)| | | | |* 1 | 0 | 23 | FILTER | | | | | | | | | |* 2 | 1 | 20 | HASH JOIN OUTER | | 116K| 8568K| 7632K| 2295K (2)| 05:56:38 | | | |* 3 | 2 | 11 | HASH JOIN OUTER | | 97611 | 6481K| 6864K| 266K (1)| 00:41:27 | | | | 4 | 3 | 9 | NESTED LOOPS | | 97611 | 5719K| | 266K (1)| 00:41:25 | | | | 5 | 4 | 7 | NESTED LOOPS | | 98629 | 5719K| | 266K (1)| 00:41:25 | | | | 6 | 5 | 5 | VIEW | VW_NSO_1 | 98629 | 674K| | 82 (3)| 00:00:01 | | | | 7 | 6 | 4 | HASH UNIQUE | | 98629 | 1338K| | 82 (3)| 00:00:01 | | | | 8 | 7 | 3 | UNION-ALL | | | | | | | | | | 9 | 8 | 1 | TABLE ACCESS FULL | B | 97591 | 667K| | 80 (3)| 00:00:01 | | | | 10 | 8 | 2 | TABLE ACCESS FULL | C | 1038 | 2076 | | 2 (0)| 00:00:01 | | | |* 11 | 5 | 6 | INDEX UNIQUE SCAN | PK_D | 1 | | | 2 (0)| 00:00:01 | | | |* 12 | 4 | 8 | TABLE ACCESS BY GLOBAL INDEX ROWID| D | 1 | 53 | | 3 (0)| 00:00:01 | ROWID | ROWID | |* 13 | 3 | 10 | TABLE ACCESS FULL | A | 45156 | 352K| | 75 (3)| 00:00:01 | | | | 14 | 2 | 19 | VIEW | | 127M| 851M| | 1988K (3)| 05:08:49 | | | | 15 | 14 | 18 | UNION-ALL | | | | | | | | | | 16 | 15 | 14 | HASH UNIQUE | | 21M| 184M| 412M| 235K (4)| 00:36:33 | | | | 17 | 16 | 13 | PARTITION RANGE ALL | | 21M| 184M| | 164K (4)| 00:25:30 | 1 | 32 | | 18 | 17 | 12 | TABLE ACCESS FULL | E | 21M| 184M| | 164K (4)| 00:25:30 | 1 | 32 | | 19 | 15 | 17 | HASH UNIQUE | | 106M| 910M| 4569M| 1752K (2)| 04:32:17 | | | | 20 | 19 | 16 | PARTITION RANGE ALL | | 238M| 2048M| | 1286K (1)| 03:19:54 | 1 | 32 | | 21 | 20 | 15 | TABLE ACCESS FULL | F | 238M| 2048M| | 1286K (1)| 03:19:54 | 1 | 32 | |* 22 | 1 | 22 | TABLE ACCESS BY INDEX ROWID | G | 1 | 36 | | 3 (0)| 00:00:01 | | | |* 23 | 22 | 21 | INDEX UNIQUE SCAN | UK_G | 1 | | | 2 (0)| 00:00:01 | | | -----------------------------------------------------------------------------------------------------------------------------------------------------