What's with the PRAGMA queries?

I see that (at least when using SQLite as a DB backend) Yii makes a lot of PRAGMA queries, typically 2 per model (table_info and foreign_key_list). I have a rather complex set of models, and it’s not uncommon for some of my pages to be going through 4 or 5 related models to find some piece of information. That could mean 10 additional queries per pageview. Since this information will be mostly static after the initial development phase, is there any way to disable these queries (for example, by statically defining the column lists and primary keys of these tables in the models)?

You can add a cache method for this to not have to change anything.

See here for more information:

http://www.yiiframew…aching.overview

I recommend to use text files for this…

you should add schemaCaching in your db configuration

Thanks, that worked. Though I still think it’s not really necessary to do any dynamic lookup for this whatsoever when the app is in production, since my table structure will remain completely static after development… It would save some performance if one could (optionally) define this information in the model.