Home > database >  Oracle range queries partition table index why don't you go?
Oracle range queries partition table index why don't you go?

Time:10-08


- create a table
The CREATE TABLE MI_TEST_NUM
(
ID VARCHAR2 (64) NOT NULL ENABLE,
PASSINGTIME TIMESTAMP (6) the DEFAULT NULL,
CREATETIME TIMESTAMP (6) the DEFAULT NULL,
The DEFAULT NULL FLAG VARCHAR2 (32),
VEHICLETYPE VARCHAR2 (30) DEFAULT null
) PARTITION BY RANGE (CREATETIME) INTERVAL (NUMTODSINTERVAL (1, 'day'))
(partition part_t01 values less than (to_date (' 2020-06-14 ', '- DD YYYY - MM)));

- create an index
The create index MITESTNUM_PASSINGTIME_localidx on MI_TEST_NUM (PASSINGTIME) LOCAL in tablespace USERS;

- query execution plan
The explain plan FOR
SELECT t. *
The FROM MI_TEST_NUM t
WHERE t.F LAG='H'
AND t.P ASSINGTIME BETWEEN to_date (' 2020-06-10 00:00:00 ', '- dd yyyy - mm hh24: mi: ss')
AND to_date (' 23:59:59 2020-06-21 ', 'yyyy - mm - dd hh24: mi: ss')
The ORDER BY t.P ASSINGTIME DESC
- check the execution plan
Select * from table (dbms_xplan. Display)

Plan the hash value: 2713456464

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
| | Id Operation | Name | Rows | Bytes | TempSpc | Cost (% CPU) | Time | Pstart | Pstop |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
2258 k | | 0 SELECT STATEMENT | | | | 629 m 167 k (1) | | 00:33:35 | | |
2258 k | 1 | SORT ORDER BY | | | | 629 m, 705 m (1) | | 167 k 00:33:35 | | |
2 | | * FILTER | | | | | | | | |
2258 k | 3 | PARTITION RANGE ALL | | | | 629 m 26024 (2) | | 00:05:13 | | 1048575 | 1
| | * 4 TABLE ACCESS FULL | JH_CAR_NUM | 2258 k | | 629 m 26024 (2) | | 00:05:13 | | 1048575 | 1
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

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

2 - filter (TO_DATE (' 2020-06-10 00:00:00 ', '- dd yyyy - mm hh24: mi: ss') & lt;=TO_DATE ('
2020-06-2123:59:59 ', '- dd yyyy - mm hh24: mi: ss'))
4 - filter (" T ". "PASSINGTIME & gt;"=TO_DATE (' 2020-06-10 00:00:00 ', '- dd yyyy - mm hh24: mi: ss') AND
"T". "FLAG"='H' AND "T". "PASSINGTIME" & lt; 23:59:59=TO_DATE (' 2020-06-21 ', '- dd yyyy - mm hh24: mi: ss'))

The problem is, I this query, indexes, why don't you go?

CodePudding user response:

May have a variety of situations, check the index whether failure, is also likely to think your statement does not walk index system more appropriate,
You try the hint forced walk index

CodePudding user response:

Know, because of large amount of data, there is no paging, paging query with respect to ok

CodePudding user response:

Since the query condition is PASSINGTIME, why on earth didn't you partition table partitioning key press PASSINGTIME this field do?
  • Related