Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
249 views
in Technique[技术] by (71.8m points)

google cloud datastore - Projection Queries vs. Regular Queries

Reading the documentation on Cloud Datastore, it's pretty clear that a Get retrieves the entire entity, and that a query is always done against the index.

Here's where it gets confusing, because according to the documentation:

Projection queries allow you to query Cloud Datastore for just those specific properties of an entity that you actually need, at lower latency and cost than retrieving the entire entity

But if all queries are done against an index, a query would never retrieve the entire entity anyway as everything is taken from the index? If I have an index with 3 properties (A, B and C) there shouldn't be any difference in using a regular query or a projection query, because I can't "project" just A and B, as the index also contains C, so in this example I would have to "project" the same properties as the regular query?

It seems to me that projection queries can only really be used when an index doesn't contain all the properties on an entity? So if an entity doesn't have a lot of properties, it doesn't make any sense to use projection because most (if not all) queries will be using/getting all the properties anyway? I'm wondering if makes sense cost-wise to use projection in this case, because the documentation says that projection has lower latency and cost but would that apply to projection when grabbing all properties?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...