Rails3 loading model schema on every request
I am running my app on heroku. It is a database intensive app and uses around 150 tables. Hence it is very slow.
I have configured newrelic to scale it and f开发者_如何学Goigure out the issue. Then I came to know that rails is firing an extra query for each used model to load it's schema on every request.
for example
SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"sub_regions"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
Is there any way , I can prevent rails to load model's schema on every request?
Any help would be highly appreciated.
Thanks
can you check that config.cache_classes = true in the production.rb file ?
Of course, you can choose what columns you want to load with ActiveRecord's select
.
See para 2.5 Selecting Specific Fields
, here.
精彩评论