question

AndreiCorovei-4687 avatar image
0 Votes"
AndreiCorovei-4687 asked AndreiCorovei-4687 commented

Cosmos DB Table API Partition key queries are very slow

We migrated our application from Table Storage to Cosmos DB Table API.

After the migration, we discovered that queries against any collection that are only against Partition Key take a lot of time to run . For example this query:

104811-image.png

took 5 minutes to run and 5k RUs on the successful request but it generated lots of 429) while this query:

104679-image.png

ran in 0.695 miliseconds and request charge was 5.72 RUs.

104802-image.png

We tried several things on the indexing part (although, I thought indexing will work out of the box like Storage does).

![104715-image.png][4]

Could someone explain this behavior?


azure-cosmos-db
image.png (74.4 KiB)
image.png (49.0 KiB)
image.png (117.0 KiB)
image.png (38.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

KalyanChanumolu-MSFT avatar image
0 Votes"
KalyanChanumolu-MSFT answered AndreiCorovei-4687 commented

@AndreiCorovei-4687 Welcome to Microsoft Q&A forums.

5 minutes and 5K RU's to retrieve 2 records is definitely not an expected behavior even when you do not specify the RowKey.
Are you seeing this consistently?
What happens when you consume the same from a client sdk?

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@KalyanChanumolu-MSFT

Yes, we ended up investigating with Fiddler and DataExplorer to nail down the queries that do not work as expected from the client sdk.

Same experience from client SDK, UI pages that have as backend a query against partition key take a very long time to load generating several 429 until the request in processed.

0 Votes 0 ·

@KalyanChanumolu-MSFT

Do you have any updates on the topic?

0 Votes 0 ·

@AndreiCorovei-4687 ·429 Error code means "Too many requests"
Requests per second on the Cosmos account are exceeding the throughput you have provisioned.

Please consider increasing the provisioned throughput and you should see the error disappear.


0 Votes 0 ·

Increasing the RUs will only increase the costs and not solve the root issue. In fact, we have increased the RUs but the query still runs in more than 5 minutes.
The problem is quite basic: querying based on partition key should return the results fast (in our case partition contain 10-12 records, max 100).
Anyways, we will continue the discussion in a support ticket.

0 Votes 0 ·