I have a suspicion that my app is having a memory leak, I read about that rails is automatically managing cache of the last 1,000 query execution. Almost every query in my app is unique and pretty heavy and contains many rows returned.
So Is there a way I can change the default value of the statement caching?
(I'm using postgres DB)
It's handled at Database Adaptor Level. There is an option to configure it by statement_limit in Postgrsql adaptor.
you need to add it in database.yml
production:
adapter: postgresql
statement_limit: 200
Follow this link for official documentation. There is an option to completely disable the statement cache.
production:
adapter: postgresql
prepared_statements: false
Secondly there is an option to clear the statement cache in postgres adaptor. There is a method named clear_cache! it can be found at Postgres adaptor
Here is a very good discussion on this same matter. You will find all the details in following links
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