oracle 绑定变量不走索引

优化来了,优化来了,

组长你来搞定嘛,结果一看,sql抓取出来,秒杀。我优化个串串。因为我看了执行计划没有错。

 

结果是绑定变量不走索引

SQL> explain plan for select /*+  first_rows(100)  */
 PHONE,
 IMSI,
 RPHONE,
 RIMSI,
 CALLEDNUM,
 TMSI,
 IMEI,
 SUBEVTTYPE,
 RESULT,
 ERRORCODE,
 RELEASERCODE,
 ERRORPHASEIND,
 FAILUREMSG,
 FAILUREPREMSG,
 RANTYPE,
 VCITY,
 MSC,
 MGWIP,
 BSC,
 LAI,
 CGI,
 ENDCGI,
 TALKLEN,
 CI  2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25  C,
 DELAY_PAGINGRES,
 DELAY_SETUP,
 DELAY_ASSIGNREQ,
 DELAY_ASSIGNCMP,
 DELAY_ALERTING,
 RRANTYPE,
 MSC_GT,
 MSCIP,
 SCP,
 SCP_GT,
 RDIRECTION,
 COMBFLAG,
 HCOUNTRY,
 HPROVINCE,
 HCITY,
 ROAMTYPE,
 HOPERATOR,
 SPECFLAG,
 CFTYPE,
 MSRN,
 RPREFIX,
 ROPERATOR,
 OCALLED,
 AUTHTIMES,
 AUTHRESULT_1ST,
 AUTHEROORCODE_1ST,
 AUCVECCOUNT,
 ENCRYALGORITHM,
 IDENTITYTYPE,
 CALLDROPFLAG,
 VIDEOBACKCAUSE,
 PAGINGTIMES,
 GLOBALFLAG,
 RELDIRECTION,
 HODURATION,
 HOTIMES,
 TDRID,
 CALLID,
 DELAY_AUTHREQ_1ST,
 DELAY_AUTHREQ_2ND,
 DELAY_AUTHRES,
 DELAY_AUCVECREQ,
 DELAY_AUCVECRES,
 DELAY_CIPCMD,
 DELAY_CIPCMP,
 DELAY_TMSICMD,
 DELAY_TMSICMP,
 DELAY_IDREQ,
 DELAY_IDRES,
 DELAY_CMREQ,
 DELAY_CMRES,
 DELAY_PAGINGREQ_1ST,
 DELAY_PAGINGREQ_2ND,
 DELAY_PAGINGREQ_3RD,
 DELAY_PAGINGREQ_MORE,
 DELAY_PAGING_NET,
 DELAY_CALLPROC,
 DELAY_IDP,
 DELAY_CONNECT_CAP,
 DELAY_RELEASE_CAP,
 DELAY_SRI,
 DELAY_SRIRES,
 DELAY_PRN,
 DELAY_PRNRES,
 DELAY_IAM,
 DELAY_ACM,
 DELAY_ANM,
 DAY_RLC,
 DELAY_RELEASE,
 DELAY_RELEASECMP,
 DELAY_CLEARREQ,
 DELAY_CLEARCMD,
 DELAY_CLEARCMP,
 USERARD,
 USERTYPE,
 IMEIRANTYPE,
 to_char(STARTTIME, 'YYYY-MM-DD HH24:MI:SS.FF') StartTime,
 to_char(EndTime, 'YYYY-MM-DD HH24:MI:SS.FF') EndTime,
 NVL((SELECT /*+index(C ind_MV_TERMINAL_tacid)*/
      TERMINALNAME
       FROM MV_TERMINAL C
      WHERE ROWNUM = 1
        AND C.TACID = SUBSTR(IMEI, 0, 8)),
     SUBSTR(IMEI, 0, 8)) TAC,
 FLOOR(CIC / (32)) PCM
  from v_CS_CallLog_Acess dt
 where 1 = 1
   and dt.endt 26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99  100  101  102  103  104  105  106  107  108  109  110  111  112  113  114  115  116  117  ime >=:1
 and dt.endtime< :2
 and dt.phone=:3118  119  ;

Explained.

SQL> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 2061439993

-----------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                       | Name                      | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
-----------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                |                           |   364K|   475M|   109K  (1)| 00:32:50 |       |       |
|*  1 |  COUNT STOPKEY                  |                           |       |       |            |          |       |       |
|   2 |   MAT_VIEW ACCESS BY INDEX ROWID| MV_TERMINAL               |  1381 |   284K|     2   (0)| 00:00:01 |       |       |
|*  3 |    INDEX RANGE SCAN             | IND_MV_TERMINAL_TACID     |   553 |       |     1   (0)| 00:00:01 |       |       |
|   4 |  VIEW                           | V_CS_CALLLOG_ACESS        |   364K|   475M|   109K  (1)| 00:32:50 |       |       |
|   5 |   UNION-ALL                     |                           |       |       |            |          |       |       |
|*  6 |    FILTER                       |                           |       |       |            |          |       |       |
|   7 |     PARTITION HASH SINGLE       |                           |   101 | 25250 | 43340   (1)| 00:13:01 |   KEY |   KEY |
|*  8 |      TABLE ACCESS FULL          | CS_CALLLOG_ACESS_18050316 |   101 | 25250 | 43340   (1)| 00:13:01 |   KEY |   KEY |
|*  9 |    FILTER                       |                           |       |       |            |          |       |       |
|  10 |     PARTITION HASH SINGLE       |                           |   101 | 25250 | 43340   (1)| 00:13:01 |   KEY |   KEY |
|* 11 |      TABLE ACCESS FULL          | CS_CALLLOG_ACESS_18050317 |   101 | 25250 | 43340   (1)| 00:13:01 |   KEY |   KEY |
|* 12 |    FILTER                       |                           |       |       |            |          |       |       |
|  13 |     PARTITION RANGE ITERATOR    |                           |   363K|   475M| 22727   (3)| 00:06:50 |   KEY |   KEY |
|* 14 |      TABLE ACCESS FULL          | CS_CALLLOG_ACESS          |   363K|   475M| 22727   (3)| 00:06:50 |   KEY |   KEY |
-----------------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter(ROWNUM=1)
   3 - access("C"."TACID"=SUBSTR(:B1,0,8))
   6 - filter(TO_TIMESTAMP(:1)TO_TIMESTAMP(:1) AND
              TIMESTAMP' 2018-05-03 16:00:00.000000000'=GREATEST(TIMESTAMP' 2018-05-03 16:00:00.000000000',TO_TIMESTAMP(:1)) AND
              "ENDTIME"TO_TIMESTAMP(:1) AND
              TIMESTAMP' 2018-05-03 17:00:00.000000000'=GREATEST(TIMESTAMP' 2018-05-03 17:00:00.000000000',TO_TIMESTAMP(:1)) AND
              "ENDTIME"=TO_TIMESTAMP(:1) AND "ENDTIME" 



号码查询不走索引, 确实问题严重。 因为我在plsql分析的时候, 都是把绑定变量替换了,分析的。


你可能感兴趣的:(oracle_sql,tuning)