One option to diagnose database performance issues is by looking at the database's currently running processes. This will give us insight into exactly what is taking up resources and potentially causing problems. In this recipe, you will be learning how to use the Heroku CLI to view and stop processes running on your database.
To begin, let's open up a terminal; we'll be using the Heroku CLI in this recipe:
To view the currently running processes on our database, we can use the
pg:ps
command. We'll see an output of what is currently running. Each process has its own unique ID (PID, or process ID):$ heroku pg:ps pid | state | source | running_for | ----+--------+----------------+-------------- 343 | active | /app/bin/rails | 00:04:23.0286
In this example, we have a query that has been running for over 4 minutes. We can stop this query with the
pg:kill
command. We use thepid
found...