question

green-9424 avatar image
0 Votes"
green-9424 asked NavtejSaini-MSFT answered

The best composite indexes for my query.

I have a query below.

SELECT *
FROM c
WHERE
  c.partition = "partition" AND
  c.date BETWEEN "2020-01-01T00:00:00.000Z" AND "2020-12-31T23:59:59.999Z" AND
  ARRAY_CONTAINS(["group_a", "group_b"], c.groups) AND
  CONTAINS(c.name, "name", true) AND
  c.deleted = null
ORDER BY
  c.sequence DESC


I'd like to add composite indexes for this query.
What index is best for it?

azure-cosmos-db
· 1
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.

@green-9424 We are checking this and will get back to you.

0 Votes 0 ·

1 Answer

NavtejSaini-MSFT avatar image
0 Votes"
NavtejSaini-MSFT answered

@green-9424

Please go through the considerations for the range and order by part of the query. Specifically if you are using the multiple range queries or system functions, it should be the last part of the index and only one of these used in single index.

87114-image.png

Please check and get back to us with questions.

Regards
Navtej S



image.png (46.8 KiB)
· 1
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.

@green-9424 Please let us know if you need any further help.

0 Votes 0 ·