Reputation: 1280
When I run an ActiveRecord query in my local console, I am shown both how long the query took to run (in ms) and the raw SQL that was generated from my ActiveRecord code. For example:
$ rails c
Running via Spring preloader in process 92420
Loading development environment (Rails 6.1.3)
[1] pry(main)> TableName.count
(26336.8ms) SELECT COUNT(*) FROM "table_names"
=> 10005457
But when I run the same query in a Heroku rails console, I don't see the query time or SQL, just the result. Example:
$ heroku run rails c
Running rails c on ⬢ app-name... up, run.9115 (Free)
Loading production environment (Rails 6.1.3)
[1] pry(main)> TableName.count
=> 10005457
If it's relevant, I have gem 'pry-byebug'
and gem 'pry-rails'
installed via my Gemfile (not in the development
group). I'm also using PostgreSQL as my database.
Upvotes: 1
Views: 683
Reputation: 3280
Whether to display query time and SQL depends on Log Levels.
It displays when the log level is :debug
or corresponding number 0
.
You could check config.log_level
in config/environments/production.rb
.
If it's :debug
, then it might be Heroku has changed log level somehow.
You could check the log level in Hereku console by Rails.logger.level
.
And set log level to :debug
by Rails.logger.level = :debug
.
Upvotes: 2