On Wed, Mar 1, 2017 at 4:23 PM, Maksim Milyutin <m.milyu...@postgrespro.ru> wrote: > As I've understood from thread  the main issue of creating local indexes > for partitions is supporting REINDEX and DROP INDEX operations on parent > partitioned tables. Furthermore Robert Haas mentioned the problem of > creating index on key that is represented in partitions with single value > (or primitive interval)  i.e. under the list-partitioning or > range-partitioning with unit interval. > > I would like to propose the following solution: > > 1. Create index for hierarchy of partitioned tables and partitions > recursively. Don't create relfilenode for indexes on parents, only entries > in catalog (much like the partitioned table's storage elimination in ). > Abstract index for partitioned tables is only for the reference on indexes > of child tables to perform REINDEX and DROP INDEX operations. > > 2. Specify created indexes in pg_depend table so that indexes of child > tables depend on corresponding indexes of parent tables with type of > dependency DEPENDENCY_NORMAL so that index could be removed separately for > partitions and recursively/separately for partitioned tables. > > 3. REINDEX on index of partitioned table would perform this operation on > existing indexes of corresponding partitions. In this case it is necessary > to consider such operations as REINDEX SCHEMA | DATABASE | SYSTEM so that > partitions' indexes wouldn't be re-indexed multiple times in a row. > > Any thoughts?
Sounds generally good. One thing to keep in mind is that - in this system - a UNIQUE index on the parent doesn't actually guarantee uniqueness across the whole partitioning hierarchy unless it so happens that the index columns or expressions are the same as the partitioning columns or expressions. That's a little a counterintuitive, and people have already been complaining that a partitioned table + partitions doesn't look enough like a plain table. However, I'm not sure there's a better alternative, because somebody might want partition-wise unique indexes even though that doesn't guarantee global uniqueness. So I think if someday we have global indexes, then we can plan to use some other syntax for that, like CREATE GLOBAL [ UNIQUE ] INDEX. But, of course, that's just my opinion. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers