2011年1月4日星期二

[fw-db] Re: Zend_Db and Postgres sequence - lots of queries

Thank you so much. You were very clear!

2010/12/31 BillKarwin [via Zend Framework Community] <
ml-node+3169097-130704122-206955@n4.nabble.com<ml-node%2B3169097-130704122-206955@n4.nabble.com>
>

>
> On Dec 30, 2010, at 2:49 AM, Vincio wrote:
>
> > 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
>
>
> ------------------------------
> View message @
> http://zend-framework-community.634137.n4.nabble.com/Zend-Db-and-Postgres-sequence-lots-of-queries-tp3168142p3169097.html
> To unsubscribe from Zend_Db and Postgres sequence - lots of queries, click
> here<http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3168142&code=dmluY2lvQGdtYWlsLmNvbXwzMTY4MTQyfC0yMDA1NzQxOTg3>.
>
>

--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Zend-Db-and-Postgres-sequence-lots-of-queries-tp3168142p3173520.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: