If I choose global index, then I will not be able to quickly drop the table partition. This is no longer true!
From 12.2 Oracle Database has asynchronous global index maintenance. This means dropping partitions is a metadata-only operation and "instant". Cleaning up the index is deferred to a background process.
For example, this creates a partitioned table with a bunch of global indexes:
create table t ( c1 primary key, c2, c3, c4, c5 )
partition by range ( c1 )
interval ( 100000 ) (
partition p0 values less than ( 100001 ),
partition p1 values less than ( 200001 )
) as
select level c1,
date'2020-01-01' + level,
timestamp'2020-01-01 00:00:00' + level,
rpad ( 'stuff', 50, 'f' ) || level,
rpad ( ' more stuff', 50, 'f' ) || level
from dual
connect by level <= 1000000;
create index i2
on t ( c2 );
create index i3
on t ( c3 );
create index i4
on t ( c4 );
create index i5
on t ( c5 );
Dropping a partition on 11.2 while maintaining the indexes takes a while - a little over 10s for me:
set timing on
alter table t
drop partition p0
update indexes;
Table T altered.
Elapsed: 00:00:12.011
Whereas on 19c removing a partition takes less than a tenth of a second:
set timing on
alter table t
drop partition p0
update indexes;
Table T altered.
Elapsed: 00:00:00.07
Connor discusses the topic of global vs. local indexes in more detail in this video: