Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-17 Thread bytte

It would be great if you could share me some more details. Maybe point me in
the right direction on how to share those PluginLoader objects between each
element?

Too bad I'm on a tight schedule (should be finished by the end of the week).
If I don't hear back from the list I'll most likely take an Ajax approach:
only loading form elements through javascript when the users needs them. But
I'm not looking forward to that to be honest.


Matthew Weier O'Phinney-3 wrote:
 
 I've worked with another user on a similar issue before. The solution we
 came up with was to share the PluginLoader objects between each element
 (by default, there are plugin loaders for each element).
 
 I'll see if I can get some more details worked up to share.
 

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



Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-17 Thread Matthew Weier O'Phinney
-- bytte thomas.bytteb...@gmail.com wrote
(on Tuesday, 17 March 2009, 09:08 AM -0700):
 It would be great if you could share me some more details. Maybe point me in
 the right direction on how to share those PluginLoader objects between each
 element?

Actually, the person I worked on it with blogged it last fall:

http://ishouldbecoding.com/2008/11/04/scaling-zend_form

That should get you started.

 Too bad I'm on a tight schedule (should be finished by the end of the week).
 If I don't hear back from the list I'll most likely take an Ajax approach:
 only loading form elements through javascript when the users needs them. But
 I'm not looking forward to that to be honest.
 
 
 Matthew Weier O'Phinney-3 wrote:
  
  I've worked with another user on a similar issue before. The solution we
  came up with was to share the PluginLoader objects between each element
  (by default, there are plugin loaders for each element).
  
  I'll see if I can get some more details worked up to share.

-- 
Matthew Weier O'Phinney
Software Architect | matt...@zend.com
Zend Framework | http://framework.zend.com/


Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-16 Thread bytte

Hi guys

Thanks to your help I managed to load the page in only 15 queries whereas
before I needed more than 1000 queries. That's great.

However my page load problem hasn't been solved. I've installed xdebug and
it lists this information:


( ! ) Fatal error: Maximum execution time of 30 seconds exceeded in
/../library/Zend/Form.php on line 2691
Call Stack
#   TimeMemory  FunctionLocation
1   0.0019  76164   {main}( )   ../index.php:0
2   0.0789  3386952 Zend_Controller_Front-dispatch( )  ../index.php:83
3   0.2307  4511976 Zend_Controller_Dispatcher_Standard-dispatch( )
../Front.php:934
4   0.2677  5380956 Zend_Controller_Action-dispatch( ) 
../Standard.php:285
5   19.1972 37326484
Zend_Controller_Action_HelperBroker-notifyPostDispatch(
)   ../Action.php:513
6   19.1974 37326900
Zend_Controller_Action_Helper_ViewRenderer-postDispatch(
)   ../HelperBroker.php:276
7   19.1976 37326916
Zend_Controller_Action_Helper_ViewRenderer-render( )
../ViewRenderer.php:962
8   19.2002 37328376
Zend_Controller_Action_Helper_ViewRenderer-renderScript(
)   ../ViewRenderer.php:923
9   19.2003 37328772Zend_View_Abstract-render( )   
../ViewRenderer.php:902
10  19.2004 37370344Zend_View-_run( )  ../Abstract.php:820
11  19.2007 37373764include(
'./application/views/scripts/inspecties/add.phtml' )../View.php:107
12  19.2009 37374412Zend_Form-__toString( )../Form.php:0
13  19.2009 37374724Zend_Form-render( )../Form.php:2610
14  19.2010 37375352Zend_Form_Decorator_FormElements-render( )
../Form.php:2595
15  34.7189 43742180Zend_Form-render( )../FormElements.php:100
16  34.7204 43744312Zend_Form_Decorator_FormElements-render( )
../Form.php:2595
17  34.7224 43747512Zend_Form-render( )../FormElements.php:100
18  34.7237 43750168Zend_Form_Decorator_FormElements-render( )
../Form.php:2595
19  36.2344 44322728Zend_Form-render( )../FormElements.php:100
20  36.2354 44323920Zend_Form_Decorator_FormElements-render( )
../Form.php:2595
21  36.2355 44325948Zend_Form-getTranslator( ) 
../FormElements.php:80
22  36.2355 44326112Zend_Form::getDefaultTranslator( )  
../Form.php:2677

I guess the problem lies in the form rendering. It makes sense as my page
loads a lot of form elements through a foreach() loop. I'm starting to feel
desperate. Anyone has any tips for me?
-- 
View this message in context: 
http://www.nabble.com/Best-coding-practice--Form-takes-too-long-to-load-now.-tp22309252p22540146.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-16 Thread Matthew Weier O'Phinney
-- bytte thomas.bytteb...@gmail.com wrote
(on Monday, 16 March 2009, 08:04 AM -0700):
 Thanks to your help I managed to load the page in only 15 queries whereas
 before I needed more than 1000 queries. That's great.
 
 However my page load problem hasn't been solved. I've installed xdebug and
 it lists this information:

I've worked with another user on a similar issue before. The solution we
came up with was to share the PluginLoader objects between each element
(by default, there are plugin loaders for each element).

I'll see if I can get some more details worked up to share.


 ( ! ) Fatal error: Maximum execution time of 30 seconds exceeded in
 /../library/Zend/Form.php on line 2691
 Call Stack
 # TimeMemory  FunctionLocation
 1 0.0019  76164   {main}( )   ../index.php:0
 2 0.0789  3386952 Zend_Controller_Front-dispatch( )  ../index.php:83
 3 0.2307  4511976 Zend_Controller_Dispatcher_Standard-dispatch( )
 ../Front.php:934
 4 0.2677  5380956 Zend_Controller_Action-dispatch( ) 
 ../Standard.php:285
 5 19.1972 37326484
 Zend_Controller_Action_HelperBroker-notifyPostDispatch(
 ) ../Action.php:513
 6 19.1974 37326900
 Zend_Controller_Action_Helper_ViewRenderer-postDispatch(
 ) ../HelperBroker.php:276
 7 19.1976 37326916
 Zend_Controller_Action_Helper_ViewRenderer-render( )
 ../ViewRenderer.php:962
 8 19.2002 37328376
 Zend_Controller_Action_Helper_ViewRenderer-renderScript(
 ) ../ViewRenderer.php:923
 9 19.2003 37328772Zend_View_Abstract-render( )   
 ../ViewRenderer.php:902
 1019.2004 37370344Zend_View-_run( )  ../Abstract.php:820
 1119.2007 37373764include(
 './application/views/scripts/inspecties/add.phtml' )  ../View.php:107
 1219.2009 37374412Zend_Form-__toString( )../Form.php:0
 1319.2009 37374724Zend_Form-render( )../Form.php:2610
 1419.2010 37375352Zend_Form_Decorator_FormElements-render( )
 ../Form.php:2595
 1534.7189 43742180Zend_Form-render( )../FormElements.php:100
 1634.7204 43744312Zend_Form_Decorator_FormElements-render( )
 ../Form.php:2595
 1734.7224 43747512Zend_Form-render( )../FormElements.php:100
 1834.7237 43750168Zend_Form_Decorator_FormElements-render( )
 ../Form.php:2595
 1936.2344 44322728Zend_Form-render( )../FormElements.php:100
 2036.2354 44323920Zend_Form_Decorator_FormElements-render( )
 ../Form.php:2595
 2136.2355 44325948Zend_Form-getTranslator( ) 
 ../FormElements.php:80
 2236.2355 44326112Zend_Form::getDefaultTranslator( )  
 ../Form.php:2677
 
 I guess the problem lies in the form rendering. It makes sense as my page
 loads a lot of form elements through a foreach() loop. I'm starting to feel
 desperate. Anyone has any tips for me?
 -- 
 View this message in context: 
 http://www.nabble.com/Best-coding-practice--Form-takes-too-long-to-load-now.-tp22309252p22540146.html
 Sent from the Zend Framework mailing list archive at Nabble.com.
 

-- 
Matthew Weier O'Phinney
Software Architect | matt...@zend.com
Zend Framework | http://framework.zend.com/


Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-09 Thread bytte

Thanks Christoph for your insightful reply. You're right. I'm using 4 nested
for each loops with a few select queries in each loop. I will try to make a
join query and then loop through the returned result array. As I understand
from your reply that should make the page load faster and put a lot less
load on the mysql server.



ChristophDorn wrote:
 
 bytte wrote:
 Hey that was interesting. I have the indexes defined and I see though
 Firebug
 that there's currently 381 queries being performed at 0.14949 seconds. I
 guess that means they're not the culprit?
   
 381 DB queries is a lot of queries for a single web page. Even if they
 only take 0.15 seconds combined, they will bring your DB server to it's
 knees as soon as you start putting some traffic through that page and
 other pages using the same DB.
 
 You are likely running DB queries in a loop which is not good practice.
 You should be using the IN SQL clause or use joins. It is much faster
 to add some more loops to your PHP than to run DB queries. If this page
 is going to be run a lot I would even check if you need to fetch the
 data from the DB on every page request or if you can cache some
 semi-static data.
 
 
 -- 
 Christoph Dorn
 http://www.ChristophDorn.com/   http://www.ChristophDorn.com/
 
 
 

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



Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-09 Thread Christoph Dorn




I cannot speak to whether the page will load faster as the queries are
executing fast on a non-loaded DB server but it should save you a lot
of trouble down the road.

Christoph


bytte wrote:

  Thanks Christoph for your insightful reply. You're right. I'm using 4 nested
for each loops with a few select queries in each loop. I will try to make a
join query and then loop through the returned result array. As I understand
from your reply that should make the page load faster and put a lot less
load on the mysql server.



ChristophDorn wrote:
  
  
bytte wrote:


  Hey that was interesting. I have the indexes defined and I see though
Firebug
that there's currently 381 queries being performed at 0.14949 seconds. I
guess that means they're not the culprit?
  
  

381 DB queries is a lot of queries for a single web page. Even if they
only take 0.15 seconds combined, they will bring your DB server to it's
knees as soon as you start putting some traffic through that page and
other pages using the same DB.

You are likely running DB queries in a loop which is not good practice.
You should be using the "IN" SQL clause or use joins. It is much faster
to add some more loops to your PHP than to run DB queries. If this page
is going to be run a lot I would even check if you need to fetch the
data from the DB on every page request or if you can cache some
semi-static data.


-- 
Christoph Dorn
http://www.ChristophDorn.com/ 	http://www.ChristophDorn.com/




  
  
  



-- 

  

  Christoph
Dorn


  
  http://www.ChristophDorn.com/

  






Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-06 Thread Christoph Dorn




bytte wrote:

  Hey that was interesting. I have the indexes defined and I see though Firebug
that there's currently 381 queries being performed at 0.14949 seconds. I
guess that means they're not the culprit?
  

381 DB queries is a lot of queries for a single web page. Even if they
only take 0.15 seconds combined, they will bring your DB server to it's
knees as soon as you start putting some traffic through that page and
other pages using the same DB.

You are likely running DB queries in a loop which is not good practice.
You should be using the "IN" SQL clause or use joins. It is much faster
to add some more loops to your PHP than to run DB queries. If this page
is going to be run a lot I would even check if you need to fetch the
data from the DB on every page request or if you can cache some
semi-static data.


-- 

  

  Christoph
Dorn


  
  http://www.ChristophDorn.com/

  






Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-04 Thread bytte

Hey that was interesting. I have the indexes defined and I see though Firebug
that there's currently 381 queries being performed at 0.14949 seconds. I
guess that means they're not the culprit?

Are there any other tools to help me find out what code makes the script run
so slow? Any help would be greatly appreciated.

Thomas B.



swilhelm wrote:
 
 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.
 
 

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



Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-04 Thread keith Pope
Are you using the meta-data cache?

2009/3/4 bytte thomas.bytteb...@gmail.com:

 Hey that was interesting. I have the indexes defined and I see though Firebug
 that there's currently 381 queries being performed at 0.14949 seconds. I
 guess that means they're not the culprit?

 Are there any other tools to help me find out what code makes the script run
 so slow? Any help would be greatly appreciated.

 Thomas B.



 swilhelm wrote:

 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.



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





-- 
--
[MuTe]
--


Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-04 Thread bytte

I'm not. I'll look into that.


keith Pope-4 wrote:
 
 Are you using the meta-data cache?
 

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



Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-04 Thread Rolando Espinoza La Fuente
On Wed, Mar 4, 2009 at 9:21 AM, bytte thomas.bytteb...@gmail.com wrote:

 Hey that was interesting. I have the indexes defined and I see though Firebug
 that there's currently 381 queries being performed at 0.14949 seconds. I
 guess that means they're not the culprit?

 Are there any other tools to help me find out what code makes the script run
 so slow? Any help would be greatly appreciated.

Try xdebug profiler, and kcachegrind if you use linux.

Regards,

-- 
Rolando Espinoza La fuente
Pro Soft Resources  Inc.
www.prosoftpeople.com


[fw-general] Best coding practice? Form takes too long to load now.

2009-03-04 Thread bytte

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.-tp22309252p22309252.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Best coding practice? Form takes too long to load now.

2009-03-03 Thread swilhelm

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.