David Rowley schrieb am 12.07.2021 um 02:57:
> Generally, there's not all that much consensus in the community that
> this would be a good feature to have. Why do people want to use
> partitioning? Many people do it so that they can quickly remove data
> that's no longer required with a simple DETACH operation. This is
> metadata only and is generally very fast. Another set of people
> partition as their tables are very large and they become much easier
> to manage when broken down into parts. There's also a group of people
> who do it for the improved data locality. Unfortunately, if we had a
> global index feature then that requires building a single index over
> all partitions. DETACH is no longer a metadata-only operation as we
> must somehow invalidate or remove tuples that belong to the detached
> partition. The group of people who partitioned to get away from very
> large tables now have a very large index. Maybe the only group to get
> off lightly here are the data locality group. They'll still have the
> same data locality on the heap.
>
> So in short, many of the benefits of partitioning disappear when you
> have a global index.
The situations where this is useful are large tables where partitioning
would turn Seq Scans of the whole table into Seq Scans of a partition,
or where it would allow for partition wise joins and still have
foreign keys referencing the partitioned table.
I agree they do have downsides. I only know Oracle as one of those systems
where this is possible, and in general global indexes are somewhat
avoided but there are still situations where they are useful.
E.g. if you want to have foreign keys referencing your partitioned
table and including the partition key in the primary key makes no
sense.
Even though they have disadvantages, I think it would be nice to
have the option to create them.
I know that in the Oracle world, they are used seldomly (precisely
because of the disadvantages you mentioned) but they do have a place.
Thomas