[Maypole] New user (pt 2?)
Marcello
m.romani@spinsoft.it
Mon, 28 Feb 2005 18:35:38 +0100
David Baird ha scritto:
>
>
> 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.
This explains some of the "2/DBI::Profile" output I've seen...
Thanks.
>
> Both pagers do the sorting on the database, not in Perl, so there's no
> difference there.
Ok.
>
> 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.
I tried CDBI::Plugin::Pager vs. CDBI::Pager with a beerdb app, 10
breweries per page with something like 10000 breweries.
The difference was not noticeable.
I would like to see the difference in another, real-world app where I
have about 2K records and some inflated columns.
So far I haven't been able to use CDBI::Plugin::Pager in that app
because it's Maypole-2.05-based, perl-5.8.3, etc., so I guess I'll have
to port the app to the updated Maypole-2.09 environment before I can do
any benchmarks.
>
> 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.
See above.
In a almost-vanilla BeerDB app you just substitute (in CDBI.pm):
use Class::DBI::Pager
with
use Class::DBI::Plugin::AbstractCount;
use Class::DBI::Plugin::Pager;
and that's all.
BTW, to see the different SQL statement used, use a dsn like this:
"dbi:mysql(Profile=>2):beerdb"
(you have to install DBI::Profile first).
When you stop the httpd-perl process, you can see a log of the executed
SQL statement and the time they took in apache's error_log
>
> 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.
Thanks. I replied to both the old and new address just in case.
If this causes trouble, I'll keep only the new sourceforge address in my
next messages.
>
> 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
>>
>