yeah i thought the same, but fetching 1k entities that way stills
takes ~2 seconds
using following code:
def __getItems(user):
userKey = __getUserKey(user,True)
t0 = time.time()
items = db.GqlQuery("SELECT * FROM Item WHERE user = :
1",userKey).fetch(1000)
logging.debug('getting items took %s ms', 1000*(time.time()-t0))
On Jan 23, 9:31 pm, Eli Jones wrote:
> This isn't very surprising.. since ret = db.GqlQuery("").get() ... it is
> only fetching one result at a time.. so.. you count one.. then it has to
> fetch the next.. and you count.. and then it has to fetch another.. etc.
>
> You should probably try db.GqlQuery("").fetch(1000) instead.
>
>
>
> On Fri, Jan 22, 2010 at 10:25 AM, Romuald Brillout wrote:
> > i am reading 1112 entities from the datastore which takes ~2.5
> > seconds.
>
> > i am wondering if such a running time is normal?
> > or did something went wrong?
>
> > anyways i'm quite surprized.
>
> > The code i use to retrieve the entities is folling:
>
> > class User(db.Model):
> > user = db.StringProperty(required=True)
> > #settings
> > set_fold = db.BooleanProperty()
> > set_inProgress = db.BooleanProperty()
> > set_sizeSort = db.BooleanProperty()
> > set_negative = db.BooleanProperty()
> > #logs
> > log_date_created = db.DateTimeProperty(auto_now_add=True)
> > log_last_visit = db.DateTimeProperty()
> > log_visit_counter = db.IntegerProperty()
>
> > class Item(db.Model):
> > user = db.ReferenceProperty(User, required=True,
> > collection_name='items')
> > id = db.IntegerProperty(required=True)
> > #info
> > type = db.IntegerProperty(required=True)
> > parent_id = db.IntegerProperty()
> > content = db.TextProperty(required=True)
> > size = db.FloatProperty(required=True,default=1.5)
> > pos = db.IntegerProperty(required=True)
> > pos_wanted = db.IntegerProperty()
> > removed = db.BooleanProperty()
> > selected = db.IntegerProperty(choices=set([0,1,2])) #0,1, or 2
> > collapsed = db.BooleanProperty()
> > xnor_select = db.BooleanProperty()
> > #logs
> > log_date_created = db.DateTimeProperty(auto_now_add=True)
> > log_last_selected = db.DateTimeProperty()
> > log_touched = db.DateTimeProperty()
>
> > def __getUserKey(user,required=False):
> > ret = db.GqlQuery("SELECT * FROM User WHERE user = :1",user.lower
> > ()).get()
> > if required and ret == None:
> > raise dbException, 'user \''+user+'\' not in database\n'
> > return ret
>
> > def __getItems(user):
> > userKey = __getUserKey(user,True)
>
> > t0 = time.time()
> > n_items = 0
> > for item in userKey.items:
> > n_items = n_items + 1
> > logging.debug('got %s items', n_items)
> > logging.debug('getting items took %s ms', 1000*(time.time()-t0))
>
> > a typical output of the __getItems function:
>
> > 01-22 07:04AM 17.782 /db.js 200 3006ms 12912cpu_ms 10249api_cpu_ms 0kb
> > Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.5 (KHTML, like
> > Gecko) Chrome/4.0.249.43 Safari/532.5,gzip(gfe)
> > 129.13.72.177 - - [22/Jan/2010:07:04:20 -0800] "GET /db.js HTTP/1.1"
> > 200 340 - "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.5
> > (KHTML, like Gecko) Chrome/4.0.249.43 Safari/532.5,gzip(gfe)"
> > "xxx.appspot.com"
> > D 01-22 07:04AM 20.778
> > got 1112 items
> > D 01-22 07:04AM 20.779
> > getting items took 2933.76612663 ms
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine" group.
> > To post to this group, send email to google-appeng...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine+unsubscr...@googlegroups.com > e...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.