Reputation: 6242
I am a little confused on the difference between query and projection queries (this is in regards to the new pricing which will be in effect July st). Say I have a Kind like this:
**POSTS:**
post_id -index
author -index
post_message -index
created -index
If I want to query all posts by an author I will retrieve N posts, N being the number of posts an author has written. So if he wrote 100 posts I will eat up 100 read requests for this query. Can I just create a dummy property and then turn the query into a projection query. So I add a property named dummy
and then I do a query but select only id, post_message, and created (author I would already know if I am filtering by it). This way it would only cost be 1 read to get all these entities. Is this possible to do? Why wouldn't everyone do this then to avoid query costs?
Upvotes: 2
Views: 334
Reputation: 3564
Projections return values from indexes rather than the entity itself so there are some limitations.
In your example, you would need to create an index on (post_id, post_message, created)
, but if you wanted to retrieve properties such as Text
or Blob
you would need to fetch the entity as those properties cannot be indexed.
You may also find that if you add properties or change properties you want to project, you will need to build new indexes. So while it may save you on some entity reads, you make some sacrifices too.
Upvotes: 2