App Engine 数据存储区定价:具有大偏移量的读取
App Engine Datastore Pricing: Reads with Large Offsets
对于我的 Google App Engine 应用程序,我经常需要在数据存储区中使用较大的偏移量(2000 或更多)。我知道这不是最佳做法,但我想知道执行这些操作的最具成本效益的方法。
我可以使用 keys_only
功能来降低成本吗?
例如,如果我进行一个 keys_only
查询,偏移量为 2000,限制为 10,然后通过键提取 10 个项目,我应该只收取 11 次数据存储读取费用,对吗?如果我不使用 keys_only
,我会为 2011 年的阅读付费,对吗?
确实,keys_only
查询会有所帮助,您的计算似乎是正确的。来自 Pricing and Quota:
Small Operations Unlimited Free
Small operations include calls to allocate Cloud Datastore IDs or
keys-only queries.
但通常您可能希望切换到使用 Cursors instead of offsets, for more reasons than just costs. From Offsets versus cursors:
Although Cloud Datastore supports integer offsets, you should avoid
using them. Instead, use cursors. Using an offset only avoids
returning the skipped entities to your application, but these entities
are still retrieved internally. The skipped entities do affect the
latency of the query, and your application is billed for the read
operations required to retrieve them. Using cursors instead of offsets
lets you avoid all these costs.
对于我的 Google App Engine 应用程序,我经常需要在数据存储区中使用较大的偏移量(2000 或更多)。我知道这不是最佳做法,但我想知道执行这些操作的最具成本效益的方法。
我可以使用 keys_only
功能来降低成本吗?
例如,如果我进行一个 keys_only
查询,偏移量为 2000,限制为 10,然后通过键提取 10 个项目,我应该只收取 11 次数据存储读取费用,对吗?如果我不使用 keys_only
,我会为 2011 年的阅读付费,对吗?
确实,keys_only
查询会有所帮助,您的计算似乎是正确的。来自 Pricing and Quota:
Small Operations Unlimited Free
Small operations include calls to allocate Cloud Datastore IDs or keys-only queries.
但通常您可能希望切换到使用 Cursors instead of offsets, for more reasons than just costs. From Offsets versus cursors:
Although Cloud Datastore supports integer offsets, you should avoid using them. Instead, use cursors. Using an offset only avoids returning the skipped entities to your application, but these entities are still retrieved internally. The skipped entities do affect the latency of the query, and your application is billed for the read operations required to retrieve them. Using cursors instead of offsets lets you avoid all these costs.