1 Definition of global index
Obviously, we need to expand Index address info(CTID) to include child table info in GlobalIndexTuple.
1.1 As mentioned in the previous email, Bruce suggested having the OID
instead of relfilenode as relfilenode can be duplicated across tablespaces.
I agree with that.
1.2 And Heikki pointed me to include heap specific information using the INCLUDE keyword so that heap information
is stored with each index node as data.
So ,In POC stage, I choose use INCLUDE keyword to INCLUDE the tableoid of global index. This will add 4 bytes to each IndexTuple.
Considering that if a single partitioned table does not exceed 65535 child tables, perhaps two bytes for tracking which child table the data belongs to is sufficient.
2. Maintenance of global index by partition table DML.
The DML of each child table of the partitioned table needs to maintain the global index on the partitioned table.
3. Global index scan
Planner:
Processes predicate on the primary partition, generating paths and plans for the global index.
The cost model of the global index may need to be considered. We need to make the global index or the local index selected in their respective advantageous scenarios.
Executer:
The index scan get indextup, get the tableoid from indextup, and verify the visibility of the data in the child table.
If a child table is DETACH, then the index item of this table is ignored during the index scan until VACUUM finishes cleaning up the global index.
4. Vacuum partition table maintains global index.
Old data in the global index also needs to be cleaned up, and vaccum is suitable for it.