![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
We have an application with range partitioned tables (Oracle 9.2.0.8). All partitioned tables use the same partitioning key column called YearMonth in YYYYMM format (type NUMBER). All indexes on partitioned tables are partitioned local. I know that partitioning key column needs to be included in unique indexes. However application vendor also included YearMonth column in many non-unique indexes, so we have two- and three-column indexes (YearMonth,AccountID), (YearMonth,TransactionID,TransactionStatus), etc. I suspect that including partitioning key column in non-unique indexes isn't required, it just makes index bigger without any benefit. We keep 2 years of data, so there are 24 partitions and 24 values of YearMonth, while there are millions of Accounts and Transactions. |
#3
| |||
| |||
|
|
We have an application with range partitioned tables (Oracle 9.2.0.8). All partitioned tables use the same partitioning key column called YearMonth in YYYYMM format (type NUMBER). All indexes on partitioned tables are partitioned local. I know that partitioning key column needs to be included in unique indexes. However application vendor also included YearMonth column in many non-unique indexes, so we have two- and three-column indexes (YearMonth,AccountID), (YearMonth,TransactionID,TransactionStatus), etc. I suspect that including partitioning key column in non-unique indexes isn't required, it just makes index bigger without any benefit. We keep 2 years of data, so there are 24 partitions and 24 values of YearMonth, while there are millions of Accounts and Transactions. |
#4
| |||
| |||
|
|
Does the SQL used by the application include the YearMonth column in lookups ( in the WHERE clause )? |
#5
| ||||
| ||||
|
|
Does the SQL used by the application include the YearMonth column in lookups ( in the WHERE clause )? Yes, it does. Let's say we have SQL statement SELECT * FROM ACCOUNTS WHERE YearMonth = :b1 and TransactionID = :b2. Case#1: Non-unique local index on (YearMonth,TransactionID): Oracle will use RANGE SCAN on one partition. |
|
Case#2: Non-unique local index on (TransactionID): As index is local and YearMonth is Partitioning Key Oracle will do partition pruning and then use RANGE SCAN on one partition. |
|
So result is exactly the same. In fact Single-column index seems better as it will also perform range scan for statement where there is no condition on YearMonth: SELECT * FROM ACCOUNTS WHERE TransactionID = :b1. |
|
Indexes need to be local as this is 24x7 system and we need to be able to drop partition without outage. |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
I think Oracle doesn't allow compression of partitioned indexes |
|
Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time Pstart| Pstop | ---------------------------------------------------------------------------------------------------- 0 | SELECT STATEMENT | | 14 | 378 | 2 (0)| 00:00:01 | | | 1 | PARTITION RANGE SINGLE| | 14 | 378 | 2 (0)| 00:00:01 | 4 | 4 | * 2 | INDEX RANGE SCAN | FOO_YM_TX | 14 | 378 | 2 (0)| 00:00:01 | 4 | 4 | |
#8
| |||
| |||
|
|
On 15.08.2011 09:51, vsevolod afanassiev wrote: I think Oracle doesn't allow compression of partitioned indexes I don't know about 9.* but I am sure that 10 does. |
#9
| |||
| |||
|
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |