VED-000 Quick test - will close soon#1286
Conversation
|
This branch is working on a ticket in the NHS England VED JIRA Project. Here's a handy link to the ticket: VED-000 |
| return [] | ||
| for vacc_type in vaccine_types: | ||
| # Should make these DB keys constants | ||
| key_condition = patient_key_condition & Key("PatientSK").begins_with(vacc_type) |
There was a problem hiding this comment.
Really interestingly, Key condition (which would be the most efficient way to run the query using the KeyCondition which uses the Partition and sort key). However, when testing (see first commit) I found that DynamoDB does not support PK equals this AND (vacc type key begins with A OR B OR C). Or conditions can only be used in the Filter Expression.
It is not explicitly called out in the docs, but sort of implied when they say that a sort key value and comparison can be provided (but not multiple): https://docs.aws.amazon.com/boto3/latest/reference/services/dynamodb/table/query.html
My approach here might ultimately be worse, because we will have to do a query per vacc type, although the query itself would be so much more efficient than what we currently are doing whereby we are retrieving all vaccinations.
Another option, besides leaving this alone and filtering client side, would be to add all the vacc type OR conditions to the FilterExpression. In truth, it's not that much more efficient as Dynamo will still retrieve all items before applying the filter, but at least it will be done server side. Will leave it up to you guys.
|



Summary
Just a quick test. Will close the PR and handover the branch as a future reference if useful.
Reviews Required
Review Checklist
ℹ️ This section is to be filled in by the reviewer.