Re: [Maypole] Maypole responding to requests very slowly (or, how to get just one associated record instead of getting the world)

From: Tony Bowden (tony-maypole at kasei.com)
Date: Thu Sep 30 2004 - 00:32:02 BST


On Wed, Sep 29, 2004 at 12:48:16PM -0400, Brian Glass wrote:
> What's happening is that Maypole is sucking down every row in the
> account table to fill the $classmetadata->{cgi} structure.
> I'm hoping the Maypole gods already have a solution for this problem... ;)

as I said earlier, this is usually a sign that your Essential columns is
too narrow.

Class::DBI's Lazy Loading mechanism means that when you fetch data from
the database for a record it only fetches the Essential columns. If you
then ask for a column that it doesn't already have it goes back to the
database for it.

When you get back a number of rows from a search or a has_many or the
like, it will do this all as one query. But if you're then calling a
column accessor method on each in turn, for a column that isn't in
Essential, it will go back to the database, in turn for each row, to
fetch that extra information. Including the column in question in your
Essential column group means it will only need that one original query.

Try adding a

        Class::Name->columns(Essential => Class::Name->columns('All'));

just to see if it makes a difference. If it does you should then choose
the most sensible list of columns to include here, as you may not want
to actually fetch back all the data for the entire table into memory in
one go!

Tony

_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:56 GMT