On Mon, Nov 30, 2009 at 11:17 PM, Matija Grabnar <mat...@serverflow.com>wrote:
> I don't think you'll find a way to use the builtin paging functions if you > later throw some rows away. > You'll have to do the paging by hand. It's even worse than that: The way > you have things set up, > if you want to show page 100, you won't know where it starts unless you > parse ALL the rows in the > preceding 99 pages. It will work if you only get a few pages usually, but > if you get high page numbers, > the whole thing will collapse. > > Ideally, I think the paging algorithm somewhere should handle a callback filter sub and be able to fetch a few more rows (until a page is completed), in case the filter dropped. Well, something in the lines: sub filter_callback { my $row = shift; return $c->localize( $row->title ) =~ /$title_filter/i; } my $rs = ...->search(undef, { page=>1, rows=>20, paging_callback=>\&filter_callback }); But I don't think implementing this is that trivial. The search-and-page algorithm would have to fetch the 20 rows, filter them out, and if there were rows thrown-out, fetch a few more, filter again... until a full 20 row page is complete (or the data set has been exhausted). At worst case, all million CD table rows are read and thrown out, which could result in a performance loss, but a working paging algorithm.
_______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk