Search code examples
postgresqlherokuheroku-postgres

PG Bench on Heroku


Is it possible to run pgbench on heroku?


Solution

  • When you connect to your Heroku database using heroku pg:psql you actually use a psql running locally on your machine to connect to the remote server.

    Similarly, you should be able to use a local pgbench even though there isn't a Heroku CLI wrapper for it. Retrieve your database connection information using heroku config:get DATABASE_URL or heroku pg:credentials, then run the command with the common connection options:

    pgbench -h HOST -p 5432 -U USER DATABASE_NAME
    

    Since it is a standard URI, you can pull the hostname, username, password, and port out of Heroku's database URL like so:

    postgres://user:password@host:port/database