Files
documentdb/internal/pg_documentdb_distributed
Deepak Bisht ad80606fda Merged PR 1668461: Disable force index pushdown for $geoNear queries
### Does this PR have any customer impact?
Yes

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

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

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

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

### Description

- $geoNear is always forced pushed to geospatial index and it can make few queries not perfrom well e.g when there are other condition that can potentially use the rum index to perform better. With this PR a GUC is introduced to disable force pushdown of geonear queries

----
#### AI description  (iteration 1)
#### PR Classification
This pull request implements a bug fix to disable force index pushdown for $geoNear queries based on a runtime GUC setting.

#### PR Summary
The changes adjust the index pushdown logic so that geonear queries can be conditionally routed based on the new configuration flag. This enhancement supports accurate geospatial query planning when the GUC is disabled.
- `oss/pg_documentdb/src/opclass/index_support.c`: Added new functions and modified the force index pushdown logic to check the `EnableGeonearForceIndexPushdown` flag.
- `oss/internal/pg_documentdb_distributed/src/test/regress/expected/bson_aggregation_pipeline_tests_geonear.out` and `pgmongo/src/test/docdb_compat/expected/bson_aggregation_pipeline_tests_geonear.out`: Introduced tests to verify runtime behavior with the GUC disabled.
- `oss/internal/pg_documentdb_distributed/src/test/regress/sql/bson_aggregation_pipeline_tests_geonear.sql`: Updated SQL tests to exercise both scenarios for geonear queries.
- `oss/pg_documentdb/src/configs/feature_flag_configs.c`: Defined a new GUC (`enable_force_push_geonear_index`) to control the pushdown behavior.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->

Related work items: #4197512
2025-05-29 12:12:31 +08:00
..