Hi Ikai, Sorry to bug you, I didn't quite follow - reworded here:
I *do* need an index on the timestamp field because I want a desc filter. This ordering may not exactly be the insertion order, but pretty close. If I wanted to present the objects by real insertion order, I'd need an additional index. Did I follow right? Yeah I don't care about insertion order really, just about the timestamp desc ordering - I figured timestamp desc and insertion order (in my case) would produce nearly identical results, so was just going to try springing on the timestamp index. Seems that I should definitely index on it though, Thanks, Mark On Wed, Jul 21, 2010 at 7:37 PM, Ikai L (Google) <[email protected]> wrote: > You'll need an index no matter what, as if you did this, you'd need Key > descending. Note that this may not be exact insert order but it'll be pretty > close. This seems to save an index, though, as doing it another way requires > both ascending and descending indexes. > > On Wed, Jul 21, 2010 at 5:52 AM, Mark <[email protected]> wrote: > >> Hi, >> >> I'm creating records of a user's actions. When I fetch these records, >> I only ever want them sorted in reverse chronological ordering (the >> order they were inserted into the datastore). Does app engine by >> default return records in this order? I'm trying to avoid having to >> keep an extra index on timestamp to reduce the number of indexes I >> use. Example (in java): >> >> class Action { >> @PrimaryKey >> @Extension(vendorName="datanucleus", key="gae.encoded-pk", >> value="true") >> private String usernameOwner; >> >> @Persistent >> long timestamp; >> } >> >> public void userActionPerformed(PersistenceManager pm) { >> pm.makePersistent(new Foo("myusername", >> System.currentTimeMillis()); >> } >> >> public void getRecords(String username) { >> String stmt = "SELECT FROM " + Action.class.getName() + " >> WHERE usernameOwner = '" + username + "'"; >> Query q = pm.newQuery(stmt); >> q.setOrdering("timestamp desc"); // want to avoid this. >> >> return (List<VRec>)q.execute(); >> } >> >> // desired html: // >> You performed a foo action on July 21 at 4:22pm! >> You performed a boo action on July 21 at 3:21pm! >> You performed a goo action on July 19 at 9:42pm! >> ... >> >> so, it would be great if I don't have to index on the timestamp - just >> get the records back in the order I inserted them - possible? >> >> Thanks >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google App Engine for Java" group. >> To post to this group, send email to >> [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<google-appengine-java%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/google-appengine-java?hl=en. >> >> > > > -- > Ikai Lan > Developer Programs Engineer, Google App Engine > Blog: http://googleappengine.blogspot.com > Twitter: http://twitter.com/app_engine > Reddit: http://www.reddit.com/r/appengine > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine for Java" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-appengine-java%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" 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-java?hl=en.
