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

首頁 > 開發 > 綜合 > 正文

檢查SQL語句是否應用了索引

2024-07-21 02:33:23
字體:
來源:轉載
供稿:網友
    檢查一條SQL語句的執行計劃,以便分析其是否應用了索引    好找到SQL的瓶頸    1。創建表plan    執行utlXPlan.sql    該文件在$Oracle_HOME/rdbms/admin下     2。在sqlplus中檢查SQL語句是否應用了索引    SQL> explain plan for (回車)
    2 select itemid from NAD_ADitem where adcustomerid<400 and adgroupid<500;
    SQL> @xpls.sql    3。xpls.sql的原文如下:    //----------------------------------------------------------------------------------------------------------------------------------
    Rem
    Rem $Header: utlxpls.sql 28-jun-99.06:02:16 kquinn Exp $
    Rem
    Rem utlxpls.sql
    Rem
    Rem Copyright (c) Oracle Corporation 1998, 1999. All Rights Reserved.
    Rem
    Rem NAME
    Rem utlxpls.sql - UTiLity eXPLain Serial plans
    Rem
    Rem DESCRipTION
    Rem script utility to display the explain plan of the last explain plan
    Rem command. Do not display information related to Parallel Query
    Rem
    Rem NOTES
    Rem Assume that the PLAN_TABLE table has been created. The script
    Rem utlxplan.sql should be used to create that table
    Rem
    Rem To avoid lines from truncating or wrapping around:
    Rem 'set charwidth 80' in svrmgrl
    Rem 'set linesize 80' in SQL*Plus
    Rem
    Rem MODIFIED (MM/DD/YY)
    Rem kquinn 06/28/99 - 901272: Add missing semicolon
    Rem bdagevil 05/07/98 - Explain plan script for serial plans
    Rem bdagevil 05/07/98 - Created
    Rem    Rem
    Rem Display last explain plan
    Rem
    select ' Operation Name Rows Bytes Cost Pstart Pstop ' as "Plan Table" from dual
    union all
    select '--------------------------------------------------------------------------------' from dual
    union all
    select rpad(' 'substr(lpad(' ',1*(level-1))operation
    decode(options, null,'',' 'options), 1, 47), 48, ' ')''
 
   rpad(substr(object_name' ',1, 29), 30, ' ')''
    lpad(decode(cardinality,null,' ',
    decode(sign(cardinality-1000), -1, cardinality' ',
    decode(sign(cardinality-1000000), -1, trunc(cardinality/1000)'K',
    decode(sign(cardinality-1000000000), -1, trunc(cardinality/1000000)'M',
    trunc(cardinality/1000000000)'G')))), 7, ' ') ''
    lpad(decode(bytes,null,' ',
    decode(sign(bytes-1024), -1, bytes' ',
    decode(sign(bytes-1048576), -1, trunc(bytes/1024)'K',
    decode(sign(bytes-1073741824), -1, trunc(bytes/1048576)'M',
    trunc(bytes/1073741824)'G')))), 6, ' ') ''
    lpad(decode(cost,null,' ',
    decode(sign(cost-10000000), -1, cost' ',
    decode(sign(cost-1000000000), -1, trunc(cost/1000000)'M',
    trunc(cost/1000000000)'G'))), 8, ' ') ''
    lpad(decode(partition_start, 'ROW LOCATION', 'ROWID',
    decode(partition_start, 'KEY', 'KEY', decode(partition_start,
    'KEY(INLIST)', 'KEY(I)', decode(substr(partition_start, 1, 6),
    'NUMBER', substr(substr(partition_start, 8, 10), 1,
    length(substr(partition_start, 8, 10))-1),
    decode(partition_start,null,' ',partition_start)))))' ', 7, ' ') ''
    lpad(decode(partition_stop, 'ROW LOCATION', 'ROW L',
    decode(partition_stop, 'KEY', 'KEY', decode(partition_stop,
    'KEY(INLIST)', 'KEY(I)', decode(substr(partition_stop, 1, 6),
    'NUMBER', substr(substr(partition_stop, 8, 10), 1,
    length(substr(partition_stop, 8, 10))-1),
    decode(partition_stop,null,' ',partition_stop)))))' ', 7, ' ')'' as "Explain plan"
    from plan_table
    start with id=0 and timestamp = (select max(timestamp) from plan_table
    where id=0)
    connect by PRior id = parent_id
    and prior nvl(statement_id, ' ') = nvl(statement_id, ' ')
    and prior timestamp <= timestamp
    union all
    select '--------------------------------------------------------------------------------' from dual;
    //----------------------------------------------------------------------------------------------------------------------------------

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 剑川县| 浦城县| 富民县| 田阳县| 三穗县| 张家川| 新巴尔虎右旗| 南充市| 会昌县| 镇江市| 延津县| 河曲县| 翁牛特旗| 姜堰市| 大冶市| 垦利县| 临颍县| 肃宁县| 梁山县| 庄河市| 抚松县| 广州市| 宜城市| 宝山区| 富阳市| 湘乡市| 米脂县| 安宁市| 祁阳县| 景泰县| 高清| 新干县| 桓台县| 大邑县| 白山市| 黔西县| 安吉县| 错那县| 鹿邑县| 天门市| 桃园县|