Query DynamoDB with different PK values

0

I am trying to use a query with KeyConditionExpression in Boto3 to query a DynamoDB table. I am trying to return all the records using the following sudo expression

(PK=X AND SK=Y) OR (PK=A AND SK=B)

OR

KeyConditionExpression=((Key("PK").eq(f"USERID#{user_id}") & Key("SK").eq(f"PROJECTID#{project_id}")) | (Key("PK").eq(f"USERID#{user_id}PROJECTID#{project_id}") & Key("SK").begins_with("LAYERID#")))

PK is the primary key and SK is the Sort Key. Does this need to be 2 separate queries and the results join or can it be done in one?

alexis
gefragt vor 3 Monaten81 Aufrufe
1 Antwort
0
Akzeptierte Antwort

You must specify a single value of the partition key in each Query request. So yes - in this case, you can make both Query calls in parallel, and then merge the result set on the application side.

beantwortet vor 3 Monaten
  • thanks Pete

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen