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

Simon Flack sf@flacks.net
Thu, 02 Dec 2004 12:27:27 +0000


Dave Howorth wrote:
>>> And something still needs to be done about the
>>> $classmetadata->{cgi} auto-creation. I have it commented out in my
>>> version of Maypole::View::Base. If you have any significant ammount
>>> of real data it causes extreme slowness.
>>
>>
>> Agreed, but it depends on your data.  I think the problem is that 
>> CDBI::AsForm->to_cgi (which is what populates classmetadata.cgi)
>> creates the HTML for all the columns (disregarding Essentials).  I
>> suppose that's a pretty sensible default since it makes it very easy
>> to get started with Maypole.  You just need an easy way of tuning
>> it/turning it off without resorting to sublassing the model. After
>> all, in M::V::TT at least, you can still do this:
>>
>> [% object.to_field('column', 'select').as_HTML %]
> 
> 
> I was confused for a minute here, until I realized there are two 
> separate topics under discussion.

Separate, but related.

> The first one is the classmetadata and I think you're both agreed that 
> it would be nice to have a means to turn it off. Somehow making it 
> evaluate lazily would be another option. Ironic perhaps, but turning it 
> into an object is my first thought :)
 >
> But the second topic is Brian's original problem, of the slow select 
> generation, and it's the to_field method (or rather its _to_select 
> helper) that causes his problem. So I don't think that calling it by 
> hand in the template is a solution! It seems to me that it would be good 
> for Brian's code to live inside _to_select.

My point was really, that if you can turn off classmetadata.cgi then you 
can still call to_field() on the columns which don't require large lookups.

I'm not sure that Brian's code needs to be in _to_select, because the 
->retrieve_all() should only populate the Essentials columns. OTOH, 
someone mentioned earlier that the Essentials may not map directly to 
what you want in the AsForm lookups. Class::DBI::TempEssential may be a 
solution to that though.

--simonflk