Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change ActiveRecord statement cache default Rails

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)

like image 522
R.Bar Avatar asked Jul 11 '26 03:07

R.Bar


1 Answers

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

like image 117
Qaisar Nadeem Avatar answered Jul 13 '26 16:07

Qaisar Nadeem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!