Try running the  Firebug profiler, Zend_Db_Profiler_Firebug, to see if its
the database queries are the culprit. I assume you already have indices
defined for the playground_id and device_id columns.

Might be time to switch to a data table like display (e.g. YUI DataTable)
containing a list of all devices with one of the columns being a link to an
"device edit" form which can simply be a separate page or with a bit more
work dynamically displayed and populated using AJAX. 

Populating the data table could then be done with a single select call that
does a join across playgrounds and checkpoints.

- Steve W.


bytte wrote:
> 
> I have a form class that creates form elements based on database
> information. The problem is that the form takes more than 20 seconds to
> load on my localhost. On the web server it's even worse: the form doesn't
> load at all because of limited memory resources.
> 
> I was hoping you guys could give me some tips on optimizing my form setup.
> The web application I'm working on is an online park administration tool
> for a company that repairs playground equipment for its clients. Every few
> months the company needs to check the status of the playground equipment.
> They can do that by filling in the form that loads form fields based on a
> few predefined checkpoints.
> 
> Eg. "Is there still enough sand in the area around the playground device?"
> etc.
> 
> I have a database with a clients table, a playgrounds table, a equipment
> table and a checkpoints table. Every client owns a few playgrounds. Every
> playground consists of some devices (equipment). And every device has a
> few checkpoints that need to be checked. Basically the form displays input
> fields for every checkpoint for every device for every playground of that
> particular client.
> 
> Currently I query the playgrounds table to find all playgrounds the logged
> in client owns.
> Then for every playground I display a subform.
> In the subform I have another subform for every playground device.
> Then I query the database to find the checkpoints for every device.
> Based on those checkpoints the form displays some form fields in the
> devices subform.
> 
> Of course I use a lot of foreach() loops to be able to display all
> necessary form fields.
> 
> foreach($playgrounds as $playground) {
>     $devices =
> $playgrounds->fetchAll($playgrounds->select()->where('playground_id =
> ?',$playground->id);
>     foreach($devices as $device) {
>         $checkpoints =
> $checkpoints->fetchAll($checkpoints->select()->where('device_id =
> ?',$device->id);
>         foreach($checkpoints as $checkpoint) {
>             //create form fields
>         }
>     }
> }
> 
> 
> I found that if there's less checkpoints the form loads way quicker. I was
> wondering if there's a better way of coding in order to have the form load
> faster.
> 

-- 
View this message in context: 
http://www.nabble.com/Best-coding-practice--Form-takes-too-long-to-load-now.-tp22309252p22313192.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to