I'm trying to write a dynamodb expression to filter certain things out. I've noticed that the following partiql is significantly more expensive than I thought it would be.
aws dynamodb execute-statement --return-consumed-capacity INDEXES --statement 'SELECT * FROM "hit_counts"."as_of_when-the_url-index-2" where "as_of_when" = ? and not contains("the_url", ?)' --parameters "[{\"S\": \"2022-06-06\"},{\"S\":\".html-dev\"}]"
*snip*
"ConsumedCapacity": {
"TableName": "hit_counts",
"CapacityUnits": 66.0,
"Table": {
"CapacityUnits": 0.0
},
"GlobalSecondaryIndexes": {
"as_of_when-the_url-index-2": {
"CapacityUnits": 66.0
}
}
}
However if I omit the contains portion in a standard query (It constantly says I can't use a primary key attribute in a filter expression), it uses significantly less capacity.
aws dynamodb query --table-name hit_counts \
--index-name as_of_when-the_url-index-2 \
--key-condition-expression 'as_of_when=:foo' --return-consumed-capacity INDEXES \
--expression-attribute-values "{\":foo\": {\"S\": \"2022-06-06\"}}" \
--select ALL_PROJECTED_ATTRIBUTES
*snip*
"ConsumedCapacity": {
"TableName": "hit_counts",
"CapacityUnits": 1.0,
"Table": {
"CapacityUnits": 0.0
},
"GlobalSecondaryIndexes": {
"as_of_when-the_url-index-2": {
"CapacityUnits": 1.0
}
}
}
What's going on here, and how does partiql actually create a query plan?