Hi,

Thanks for the response, that gave me a good foot in the door to this.
I've now appened my existing query with.

.order_by('myobject.created')[:1000]

Which appears to give the desired result set, however, when looking
through the SQL debug output it seems that the limit their is applied
using python and not SQL, in as much as SQL returns ALL the records
and then the app splits it up. This doesnt feel particularly
performant too me and I would ideal prefer the limit to be imposed at
a SQL level, is this possible?

Thanks for your advice so far,

Heston

On Sep 24, 12:06 pm, [EMAIL PROTECTED] wrote:
> first u get your query sorted in proper order (by timestamp or even
> dbid, or hierarchicaly via subselect + groupby + order, whatever)
> then yourquery[:1000]
>
> On Wednesday 24 September 2008 14:11:24 Heston James - Cold Beans
> wrote:
>
>
>
> > Morning Guys,
>
> > I hope this'll be a fairly simple question. I have a query which
> > looks something like this:
>
> > the_objects =
> > session.query(myobject.myobject).filter("myobject.created >
> > :lastrecord").params(lastrecord=time.strftime("%Y-%m-%d %H:%M:%S",
> > from_date)).all()
>
> > This grabs all the records after a particular date and time. What I
> > WANT it to achieve though is to grab the first 1000 records that
> > happen after a period in time. How would you suggest that I handle
> > my limits and order_by's on this? It's important that no records
> > get missed out you see so I need to be totally sure that the 1000
> > records returned are the first 1000 records in chronological order
> > after 'from_date'.
>
> > I'm using SQLAclchemy 0.5 and MySQL 5
>
> > I appreciate any advice you can offer.
>
> > Cheers,
>
> > Heston- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to