PS: running locally, haven't tried live yet because i'm doing my tests
with 20k test models that i can't yet generate online

No dia 30 de Março de 2010 02:01, José Moreira
<[email protected]> escreveu:
> I need to get the 1st and last result from a query that uses only keys
> (and they keys are what i need), i'm even using a cached cursor:
>
>
> q = self.model.all(keys_only=True).order('__key__') # fetch/return only keys
>
> #maybe there's a better way to get the 1st/last key (taking too long)
>
> if self.job.currentCursorKey is not None:
>        # 1st request
>        logging.debug("\tusing last cursor: %s" % self.job.currentCursorKey)
>        q.with_cursor(self.job.currentCursorKey)
>
>
> after this i'm trying two methods:
>
> A)
>
> # Fetch method
> users_keys      = q.fetch(limit)
> startKey        = str(users_keys[0])
> endKey  = str(users_keys[-1])
>
> B)
>
> # Double query method
> startKey        = str(q.get())
> users_keys      = q.fetch(limit=1, offset=limit) # get the endKey of the 
> segment
> endKey  = str(users_keys[0])
>
>
> but both take too long (7/8 seconds at least). Should i refactor to
> GQL for example and do 2 SELECT's? One for the 1st and another for the
> 2nd?
>
>
>
>
>
> --
> [email protected]
> http://beta.icodedhere.com
> http://pt.linkedin.com/in/josemoreira
> http://djangopeople.net/josemoreira
> http://www.crunchbase.com/user/josemoreira
>



-- 
[email protected]
http://beta.icodedhere.com
http://pt.linkedin.com/in/josemoreira
http://djangopeople.net/josemoreira
http://www.crunchbase.com/user/josemoreira

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to