[Maypole] New user (pt 2?)
David Baird
dave@riverside-cms.co.uk
Mon, 28 Feb 2005 17:15:55 +0000
Marcello wrote:
>
> Maypole speed is an issue for me too.
> I think the problem is not in maypole itself but in how
> class::dbi::pager handles pagination.
> From what I understood so far, if you have 100 records and want to
> display 10 of them per page, the whole recordset gets loaded in memory
> (so you get 100 objects in memory, with foreing keys columns inflated,
> etc.), then the 80 non relevant object get discarded.
> This causes a lot of CPU and memory consumption.
> A first optimization is to use the 'lazy population' cdbi feature.
> I have to admit it did not much for me, but maybe I only have to better
> understand the relationship between 'Essential' columns and column
> inflation...
> I substituted Class::DBI::Pager with Class::DBI::Plugin::Pager, which
> makes use of the LIMIT clause when working with MySQL, but did so in a
> very simple beerdb sample app, and I didn't notice any significant
> speedup. Have to try it on the production app (which has tables with
> 1000s of records and 10s of inflated columns) and see what happens.
No, with CDBI::Pager you get a CDBI iterator, which is much more
lightweight than fully blown CDBI objects. The iterator stores IDs (I
guess) of the 100 rows. Then CDBI::Pager slices out the relevant 10 rows
into a new iterator.
Both pagers do the sorting on the database, not in Perl, so there's no
difference there.
For searches returning hundreds of rows, I doubt if CDBI::Plugin::Pager
would be much faster or less memory hungry. It should start to be worth
looking at for thousands of rows. I haven't done any benchmarking, but
that'd be my guess.
On substituting CDBI::Pager with CDBI::Plugin::Pager in Maypole, see a
recent thread on this list. Basically, dropping CDBI::Plugin::Pager
might seem to work, but I think that's false. I haven't tried it yet
myself, but you'd need to rewire bits of Maypole::Model::Base, or else
of CDBI::Plugin::Pager.
Note that this list has moved to sourceforge, and will disappear from
the netthink address in due course. See maypole.perl.org for new links.
d.
>
> HTH, HAND
>
> Marcello
>
>>
>> Any example sites that are using maypole? Or even class::dbi + TT based
>> dynamic sites?
>> Thanks for reading and/or replying to this... :)
>>
>> Imran
>>
>> -------
>> package Naweb::JokesAdmin;
>>
>> #use base 'Maypole::Application';
>> use Maypole::Application;
>>
>> __PACKAGE__->setup("dbi:mysql:jokes","usr","pass");
>> __PACKAGE__->config->uri_base("http://www.niazi.net/perl/jokes");
>> __PACKAGE__->config->template_root("/web/niazi/perl/jokes");
>> __PACKAGE__->config->rows_per_page(20);
>> __PACKAGE__->config->display_tables([qw[joke]]);
>>
>> Naweb::JokesAdmin::Joke->untaint_columns(
>> printable => [qw/joke_type rating credit title content answer/],
>> date => [ qw/date/ ] );
>>
>>
>> _______________________________________________
>> maypole mailing list
>> maypole@lists.netthink.co.uk
>> http://lists.netthink.co.uk/listinfo/maypole
>>
>
>
> _______________________________________________
> maypole mailing list
> maypole@lists.netthink.co.uk
> http://lists.netthink.co.uk/listinfo/maypole
>