On Feb 24, 2011, at 2:20 PM, Chris Withers wrote:

> What if the primary key is not numeric?

It would depend on what is being paginated of course. Most db's that sort data, 
can do > or < on any key they can sort on, so that'd still work though it'd of 
course require the key used to be unique. Ie, if it was sorted on date, and 
there were a ton of things on the same dates, then it wouldn't be applicable.

> This I don't follow, lack of relational knowledge.
> I presume you mean the OFFSET is slow on the server?

Yes, though how slow depends on the db server. Of course, lets not presume the 
only thing paginated are results from an RDBMS. People paginate data from 
no-sql db's, and some either have incredibly slow 'offset' (or skip as I think 
CouchDB calls), or just plain recommend that you use start keys at all times 
due to how the data is stored and distributed on a cluster.

>> 3) You'd have to transmit the last primary key to the next request as
>> a query param.
> 
> But how is that different from having to transmit the page number to the next 
> request?

Right, it isn't. In PylonsHQ for example, since it uses CouchDB which highly 
emphasizes using a key vs. a 'skip', the URL's look like:
http://pylonshq.com/pasties?start=51&startkey=2011-01-12T20:31:27Z

so that it can keep track of the approx. number its up to and the startkey. The 
other handy thing about using a key in the URL for paginated results... is that 
things don't usually move around much for the URL. That URL above is going to 
show the same exact results in a week as it does now, even though a whole bunch 
of new pastes will be added.

> session.query(MyModel)
> 
> What's the most efficient way I can do that with currently available software?
> 
> What version of webhelpers should I use? Are there any changes to the query I 
> should make to make it more efficient?

The current Paginate in webhelpers can do that just fine.

Cheers,
Ben

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to