mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 19:59:54 -05:00
### Does this PR have any customer impact? Yes ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Perf ### 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 ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ### Description 1) In the Gateway, when preparing queries, embed the commandKey and userOid. That way a given prepared query is unique for a given user and command. This can be used for a future optimization to cache ACL check results 2) Reduce serialization costs from GW -> BE: Don't send the database name in the query. This is already in the request as a '$db' field. Support suppressing this (add a GUC to rollback just in case) 3) In the backend start parsing the $db if it's not sent by the GW 4) From the commandFuncs -> Query we were going through a layer of fmgr. We don't need this. Instead call directly into the functions in C to avoid the fmgr overhead. Additionally for GetMore this means we don't need to repack the heap tuple. As part of this we discovered that registering functions in pg_dist_object can regress perf for dispatch functions. Add a test to validate which ones of these are public. ---- #### AI description (iteration 1) #### PR Classification Performance improvement. #### PR Summary This pull request focuses on enhancing the performance of read and query operations by optimizing function calls and parameter handling. - Refactored `ExecuteQueryCore` in `command_funcs.c` to improve query execution by directly calling specific functions and adding ACL checks. - Changed function signatures in `bson_aggregation_pipeline.h` to use `text` instead of `Datum` for database parameters, improving type consistency. - Added `aggregation_commands.h` to export new aggregation command functions. - Updated `PostgresClient.cs` to conditionally include database names in query parameters, enhancing query flexibility. - Introduced new configuration option `SendDatabaseNameInParams` in `PostgresTenantConfiguration.cs` to control database name parameterization. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->