Is it possible to get only some properties with NDB?

89 views
Skip to first unread message

Kaan Soral

unread,
Mar 28, 2012, 4:51:46 PM3/28/12
to google-a...@googlegroups.com
Lets say I have a model and it has numerous properties, with A,B,C,D properties, all being 1MB's, so total size is roughly ~4MB's, and other properties being insignificantly small.

Is it possible to only fetch certain properties with entities? - For example - as it is - if I fetched 100 entities, it would require 400MB's of RAM [too much]. (I don't need A,B,C,D for that query result)

I am trying to figure out If I should separate some properties to different_models to ease querying, or does NDB solve this problem with some built-in functions. (I have checked the documentation, not so deeply, couldn't find anything).
I think discovering-learning functionalities like these are very important while designing a system, so I am trying to learn NDB in depth, for this reason any tips regarding NDB are also appreciated. (For example, what problems does ndb solve that are unsolvable or unpractical using db )

Thanks in Advance

Nick Johnson

unread,
Mar 29, 2012, 8:29:51 AM3/29/12
to google-a...@googlegroups.com
Entities are stored and retrieved as a single unit by the underlying datastore layer, so NDB, like all other APIs to it, retrieves and stores only complete entities. If you want to retrieve only parts, you'll have to split your model up into separate models, instead.

Note that entities are limited to 1MB each, too, so 4 1MB properties are not possible.

-Nick



--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/V_wp9a9MTAUJ.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.



--
Nick Johnson, Developer Programs Engineer, App Engine


Kaan Soral

unread,
Mar 29, 2012, 6:25:30 PM3/29/12
to google-a...@googlegroups.com
Thanks a lot for the reply

I am shocked to learn about the total 1MB limit for any datastore entity, I thought it was only for properties

Tom Davis

unread,
Mar 30, 2012, 9:55:50 AM3/30/12
to google-a...@googlegroups.com

Over time, you'll stop being shocked and just expect things to be seriously
limited. Honestly, you don't *want* 1MB entities (and God help you if it were
really per-property!). If you've got a lot of them, it becomes prohibitively
slow and difficult to do anything with them except fetch a few at a time
occasionally. Transactions will take far longer, too, meaning concurrent access
will produce higher and higher error rates. If you really need to store lots of
data, use the Blobstore. Once you reach larger entity sizes, it's the only
reasonable access model anyway.

>
> >
>
> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.

> To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/QzqqnMArXpcJ.

Reply all
Reply to author
Forward
0 new messages