in reply to Class::DBI Pagination with Table Joins

Why do you want to paginate the data? For human consumption?

If so, then I say "Don't do that.". And here's why: Nobody can grok that much data in the first place. Use SQL to give them the records they need at that point in time. For example, start with the top/first CD, LIMIT (an SQL keyword) 30. Then, do an OFFSET (another SQL keyword) 30, LIMIT 30, and so on...

Of course if this isn't for human consumption, well, then, nevermind... <g>

  • Comment on Re: Class::DBI Pagination with Table Joins

Replies are listed 'Best First'.
Re^2: Class::DBI Pagination with Table Joins
by thor (Priest) on Oct 13, 2005 at 15:08 UTC
    I thought that pagination meant giving the data to a user a chunk at a time. Which is why your post confuses me; you say "don't do that" and then say "here's how to impliment pagination".

    Also, I don't think that LIMIT is as universal as you might think. It works in Postgres and MySQL, but I know that it doesn't work in Sybase at the time of this writing.

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

      You're right, I wasn't clear, sorry. What I meant was: Yes, do the pagination, but No, don't pull X-thousand records to do it. Paginate by pulling only what you need. (Think Just-In-Time inventory, except w/ records.)

      I can't speak Sybase SQL, and we all know that sometimes SQL seems like it's more dialect than ANSI. I've used LIMIT and OFFSET with success in my own work though, and it's *really* handy for this kind of work.

        Howdy!

        Last time I did Sybase, one could "set recordcount=x" to limit the result set to x rows, but I don't recall any analog to OFFSET. Of course, if you do pagination by repeated queries, how worried are you about getting the same result set each time (from which you draw a different subset)? If the data is fairly static, or you don't care, you can just do a fresh query each time. Otherwise, you want an iterator-like middleman to do the big query and hand you x rows at a time on demand.

        yours,
        Michael
Re^2: Class::DBI Pagination with Table Joins
by jgallagher (Pilgrim) on Oct 13, 2005 at 15:13 UTC
    Like thor, I'm curious as to what you mean by "paginate" - your second paragraph describes how I would go about doing it by hand. But, this being Perl, I'd rather not do anything by hand that has already been done by someone else. :-)