Files
Santiago Fernandez Madero 3245167027 Merged PR 1749636: [Composite] Prefer composite indexes over non composite on the planer layer
### Does this PR have any customer impact?

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)

### Are you introducing any new config? If yes, do you have tests with and without them being set?

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description

[Composite] Prefer composite indexes over non composite on the planer layer

This implements the get_rel_info_hook and reorders the rel indexlist based on the following ordering:

1. primary key index
2. composite index
3. regular indexes
4. wildcard indexes
5. Any other index

This also renames enableCompositeTerm to enableOrderedIndex option on the metadata options we return to the user

----
#### AI description  (iteration 1)
#### PR Classification
Feature enhancement: this PR updates the planner to preferentially use composite indexes over non-composite ones.

#### PR Summary
The pull request implements index ordering logic in the planner to favor composite indexes by introducing new sorting and logging functions, replacing the legacy “enableCompositeTerm” with “enableOrderedIndex”, and updating the associated feature flags and tests.
- **`src/planner/documents_planner.c`**: Added functions (e.g., `GetIndexOptInfoSortOrder`, `CompareIndexOptionsFunc`, and `ExtensionGetRelationInfoHook*`) to prioritize indexes so that composite indexes rank higher.
- **`src/configs/feature_flag_configs.c` and `src/configs/testing_configs.c`**: Introduced new boolean flags (`enableIndexPriorityOrdering` and `logRelationIndexesOrder`) to control the index ordering and logging behavior.
- **`src/metadata/index.c` and `src/commands/create_indexes.c`**: Updated index creation and comparison logic to replace `enableCompositeTerm` with `enableOrderedIndex` for consistent composite index handling.
- **Test files (under `/oss/pg_documentdb/src/test/regress/` and `/pgmongo/src/test/`)**: Revised expected outputs and SQL tests to validate that composite indexes are now preferred in the query planner.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-08-07 11:14:08 +08:00
..