data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

[Enhancement]: optimise for point read in config to use Cosmos ReadItemAsync

Open golfalot opened this issue 1 year ago • 0 comments

What happened?

With a 2,460 byte document, The cost for a point read is 1.05 RUs, whereas the equivalent SELECT * FROM c WHERE c.id = '{documentId}' (where the partition key is /id), the cost is 2.85 RUs

I understand this tool is doing a lot of generic resolving quite brilliantly across multiple data sources, but I and possibly a good many others have datasets in Cosmos which we interrogate using the Cosmos SDK to run cost efficient point reads with ReadItemAsync

I would love an option to specify in my configuration for a given entity that I want the resolver to use ReadItemAsync.

  • we'll need a way to specify in config which field names from the schema represent the document id and partition key for ReadItemAsync to use as parameters
  • we'll need also need a way to remove fields from the response object which were not requested in the GraphQL query
  • I also note this could consume more RUs for very large documents than a comparable SQL api query due to returning unwanted fields

I have a had a look through the source to see how this project hangs together, it's very elegant, but I very much feel offering a pull request is out of my league.

Thank you considering this enhancement. Tim.

Version

1.2.11+c7ca8db8558a63919c530e454c8f18b45d5b931c

What database are you using?

CosmosDB NoSQL

What hosting model are you using?

Local (including CLI)

Which API approach are you accessing DAB through?

GraphQL

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

golfalot avatar Sep 27 '24 17:09 golfalot