> I saw using Zend_Db_Profiler_Firebug that Zend does a lot of queries
> just to
> know the sequenceid, I guess.
It's not related to the sequenceid. This query is in the Db Adapter's
describeTable() method, querying metadata about your table. This is
run typically during initialization of any of your classes that extend
Zend_Db_Table_Abstract. That is, when you do:
$mytable = new MyTable();
The base Table class tries to discover metadata about the database
table that your MyTable class is defined for. The benefit of this is
that you *don't* have to write a bunch of tedious XML config files
before you can get your tables to run, as you would have to in many
other types of ORM products.
> I thought that this could become to be a big problem. For example if
> I got
> about 200 hundred queries more than half are queries like that one.
Naturally, you want to create object instances frequently in your
application. Generating that big query against system views 100 times
per request seems kind of expensive. Especially since the table
structure is not likely to change during that time. There is a
solution! Read on...
> Is it normal? Is there a way to limit these queries?
Yes, you can assign a Zend_Cache object to keep the metadata alive and
reuse it for multiple instances of your Table class(es), even across
multiple PHP requests. It doesn't define a metadata cache by default
because you have to choose what cache implementation you want to use.
For details about using metadata caching, read:
http://framework.zend.com/manual/en/zend.db.table.html#zend.db.table.metadata.caching
Regards,
Bill Karwin
没有评论:
发表评论