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
질문됨 3달 전81회 조회
1개 답변
0
수락된 답변

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.

답변함 3달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠