国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

MySQL中對于not in和minus使用的優(yōu)化

2024-07-24 12:46:09
字體:
來源:轉載
供稿:網友

優(yōu)化前:

select count(t.id) from test t where t.status = 1 and t.id not in (select distinct a.app_id from test2 a where a.type = 1 and a.rule_id in (152, 153, 154)) 17:20:57 laojiu>@planPLAN_TABLE_OUTPUT————————————————————————————————————————-Plan hash value: 684502086—————————————————————————————-| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |—————————————————————————————-| 0 | SELECT STATEMENT | | 1 | 18 | 176K (2)| 00:35:23 || 1 | SORT AGGREGATE | | 1 | 18 | | ||* 2 | FILTER | | | | | ||* 3 | TABLE ACCESS FULL| test | 1141 | 20538 | 845 (2)| 00:00:11 ||* 4 | TABLE ACCESS FULL| test2 | 1 | 12 | 309 (2)| 00:00:04 |—————————————————————————————-Predicate Information (identified by operation id):————————————————— 2 – filter( NOT EXISTS (SELECT /*+ */ 0 FROM “test2″ “A” WHERE “A”.”type”=1 AND (“A”.”RULE_ID”=152 OR “A”.”RULE_ID”=153 OR “A”.”RULE_ID”=154) AND LNNVL(“A”.”APP_ID”<>:B1))) 3 – filter(“T”.”status”=1) 4 – filter(“A”.”type”=1 AND (“A”.”RULE_ID”=152 OR “A”.”RULE_ID”=153 OR “A”.”RULE_ID”=154) AND LNNVL(“A”.”APP_ID”<>:B1))Statistics———————————————————- 0 recursive calls 0 db block gets 1762169 consistent gets 0 physical reads 0 redo size 519 bytes sent via SQL*Net to client 492 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed21 rows selected.

優(yōu)化后:

select count(*) from( select t.id from test t where t.status = 1 minus select distinct a.app_id from test2 a where a.type = 1 and a.rule_id in (152, 153, 154))17:23:33 laojiu>@planPLAN_TABLE_OUTPUT————————————————————————————————————————-Plan hash value: 631655686————————————————————————————————–| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |————————————————————————————————–| 0 | SELECT STATEMENT | | 1 | | | 1501 (2)| 00:00:19 || 1 | SORT AGGREGATE | | 1 | | | | || 2 | VIEW | | 1141 | | | 1501 (2)| 00:00:19 || 3 | MINUS | | | | | | || 4 | SORT UNIQUE | | 1141 | 20538 | | 846 (2)| 00:00:11 ||* 5 | TABLE ACCESS FULL| test | 1141 | 20538 | | 845 (2)| 00:00:11 || 6 | SORT UNIQUE | | 69527 | 814K| 3632K| 654 (2)| 00:00:08 ||* 7 | TABLE ACCESS FULL| test2 | 84140 | 986K| | 308 (2)| 00:00:04 |————————————————————————————————–Predicate Information (identified by operation id):————————————————— 5 – filter(“T”.”status”=1) 7 – filter(“A”.”type”=1 AND (“A”.”RULE_ID”=152 OR “A”.”RULE_ID”=153 OR “A”.”RULE_ID”=154))21 rows selected.Statistics———————————————————- 1 recursive calls 0 db block gets 2240 consistent gets 0 physical reads 0 redo size 516 bytes sent via SQL*Net to client 492 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 2 sorts (memory) 0 sorts (disk) 1 rows processed
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 威信县| 阜宁县| 宜都市| 武穴市| 靖安县| 辛集市| 合江县| 屏边| 德令哈市| 海门市| 额济纳旗| 高阳县| 英德市| 永德县| 冷水江市| 福海县| 日喀则市| 油尖旺区| 罗源县| 城口县| 南乐县| 资溪县| 馆陶县| 肇庆市| 长沙市| 陆川县| 凤翔县| 靖宇县| 古浪县| 方正县| 临洮县| 贵定县| 宝山区| 桓台县| 略阳县| 偏关县| 珠海市| 平邑县| 娱乐| 读书| 高阳县|