Skip to content

[@azure/cosmos] huge overhead when performing SQL query with SDK #24376

Open

Description

  • Package Name: @azure/cosmos
  • Package Version: 3.17.2
  • Operating system: MacOS
  • nodejs
    • version: 18.12.0
  • browser
    • name/version:
  • typescript
    • version:
  • Is the bug related to documentation in

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Create a SQL request involving multiple statements, like this one (metrics added to check query performance):
const { resources, queryMetrics } = await this.rolls.items
    .query(`SELECT TOP 10 * from r WHERE r.sides = 6 ORDER BY r.timestamp DESC`, { populateQueryMetrics: true})
    .fetchAll();

On my local environment, a request like this takes ~750ms on the first call, then ~400ms on subsequent calls (using a Cosmos DB with serverless tier and Core SQL API).

For comparison, a simple GET item by id or create item take ~110ms (about 100ms is because of HTTP latency, most of the rest is framework overhead).

Query metrics indicates that the query takes ~0.05ms to execute, and I get the same number in Data Explorer.

Expected behavior
Same performance as when doing a create/get by id request given the request metrics. Excluding the ~100ms latency, there's a 300ms overhead when trying to perform a SQL query with the JS SDK, which is definitely not ok.

Am I missing something here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.CosmosService AttentionWorkflow: This issue is responsible by Azure service team.hacktoberfest

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions