I just set up FirePHP in Zend and I'm noticing a huge number of DESCRIBE queries. Some pages have 50 or more identical queries all on the same table. e.g.
0.00198 connect NULL 0.00449 DESCRIBE `nodes` NULL 0.00041 SELECT `nodes`.* FROM `nodes` WHERE (((`nodes`.`id` = 111))) NULL 0.0037 DESCRIBE `nodes` NULL 0.00155 SELECT `nodes`.* FROM `nodes` WHERE (((`nodes`.`id` = 111))) NULL 0.00059 SELECT `nodes`.* FROM `nodes` WHERE (parent_id = '111') ORDER BY `order` ASC, `id` ASC NULL 0.00366 DESCRIBE `nodes` NULL 0.0054 DESCRIBE `nodes` NULL 0.0049 DESCRIBE `nodes` NULL 0.00519 DESCRIBE `nodes` NULL 0.00492 DESCRIBE `nodes` NULL 0.00691 DESCRIBE `nodes` NULL 0.00741 DESCRIBE `nodes` NULL 0.0048 DESCRIBE `nodes` NULL 0.00556 DESCRIBE `nodes` NULL 0.00516 DESCRIBE `nodes` NULL 0.00487 DESCRIBE `nodes` NULL
...and it goes on.
Are all those DESCRIBE queries generated by the framework (I'm using Zend_DbTable)? Are they all necessary? Should I be worried about them or are they not likely to be impacting performance?
Those queries are executed by Zend_Db_Table to detect the schema of the tables. You can ask Zend_Db_Table to cache the results using a Zend_Cache to prevent constant calls, but bare that in mind if you change the schema.
You can do so by using:
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
Zend_Db_Adapter_Abstract::describeTable()
does these queries to get the Metadata of your tables when using Zend_Db_Table
This is used for instance when you do not specify a primary key explicitly. You can enable the MetaData cache or just use Zend_Db
instead of Zend_Db_Table
.
I think you should not have this many describe queries though. Once a Zend_Db_Table
instance is set up, it will store the metadata after the first query for the remaining request. Try to use Zend_Debugger or Xdebug to find out what's causing this.
See
Zend_Db_Adapter_Abstact::describeTable()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With