mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
### 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? ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description Push sort by _id down to the primary key index on unsharded or when we have a shard key ---- #### AI description (iteration 1) #### PR Classification Code optimization #### PR Summary This pull request optimizes the sorting mechanism by pushing the sort by `_id` down to the primary key index when applicable. - Added `CanSortByObjectId` and `HasShardKeyFilterWalker` functions in `bson_aggregation_pipeline.c` to determine if sorting by `_id` can be optimized. - Modified `HandleSort` function in `bson_aggregation_pipeline.c` to use the new optimization logic for sorting by `_id`. - Updated function declarations in `bson_aggregation_pipeline.c` to include the new helper functions.