Ongoing mongoac development highlighted a significant performance overhead attributed to Database::run_raw_command()'s return type being Result<Document> rather than Result<RawDocumentBuf>.
Every reply document, whose size and complexity depends on the arbitrary command given to the function, is recursively-parsed in its entirety during conversion of the RawDocumentBuf (within RawCommandResponse) into Document. Database::run_raw_command() in its current form addresses this problem for the command parameter (as alternative to Database::run_command()), but not for the return value.
Ultimately it may be worth considering extending the RawDocumentBuf-based behavior of run_raw*() API to their return types, not just their parameters, in a future major release. In the interim, this ticket proposes the addition of a feature-gated API instead, e.g.:
impl Database {
pub fn run_raw_command_2(&self, command: RawDocumentBuf) -> RunRawCommand<'_>
{ ... }
}
impl<'a> Action for RunRawCommand<'a> {
async fn execute(self) -> Result<RawDocumentBuf>
{ ... }
}
Note: "runCursorCommand()" can avoid this intermediate Document conversion problem by using Cursor::with_type::<RawDocumentBuf>().
- is depended on by
-
CDRIVER-6570 Refactor DatabaseT::run_command() to use the improved RawDocumentBuf API
-
- Blocked
-
- is related to
-
CDRIVER-6506 Support DatabaseT::runCommand
-
- Closed
-