Reputation: 15985
I am trying to setup PgHero in an application. I keep on getting following error
Started GET "/pghero" for 127.0.0.1 at 2014-09-09 12:35:41 +0530
Processing by PgHero::HomeController#index as HTML
Geokit is using the domain: localhost
(3.9ms) SELECT COUNT(*) AS count FROM pg_extension WHERE extname = 'pg_stat_statements'
CACHE (0.0ms) SELECT COUNT(*) AS count FROM pg_extension WHERE extname = 'pg_stat_statements'
(1.5ms) SELECT pid, state, application_name AS source, age(now(), xact_start) AS duration, waiting, query, xact_start AS started_at FROM pg_stat_activity WHERE query <> '<insufficient privilege>' AND state <> 'idle' AND pid <> pg_backend_pid() AND now() - query_start > interval '1 minutes' ORDER BY query_start DESC
PG::Error: ERROR: column "pid" does not exist
LINE 1: SELECT pid, state, application_name AS source, age(now(), xa...
^
: SELECT pid, state, application_name AS source, age(now(), xact_start) AS duration, waiting, query, xact_start AS started_at FROM pg_stat_activity WHERE query <> '<insufficient privilege>' AND state <> 'idle' AND pid <> pg_backend_pid() AND now() - query_start > interval '1 minutes' ORDER BY query_start DESC
I followed all steps and troubleshooting mentioned in the documentation
postgresql.conf
shared_preload_libraries = 'pg_stat_statements'
custom_variable_classes = 'pg_stat_statements'
pg_stat_statements.track = all
After restarting PG server, I created the extension using CREATE extension pg_stat_statements;
and then reset statistics using SELECT pg_stat_statements_reset();
There after I restarted Rails server and hitting /pghero
give same error.
It looks like pgsql issue. I am not good at pg admin. Can anybody please show me the way to fix it?
Upvotes: 1
Views: 2661
Reputation: 324265
Use PostgreSQL 9.2, or see if there's an older pghero version that supports 9.1. Which there doesn't seem to be, given that:
Supports PostgreSQL 9.2+
is right there near the top of the README.
Explanation for the error:
The pid
column in pg_stat_activity
was named procpid
on PostgreSQL 9.1 and older. This tool seems not to check the PostgreSQL version and use the appropriate name, it just assumes it's talking to 9.2 or newer.
So you could add a check for the value of SELECT current_setting('server_version_num')
to PgHero that makes it switch to the old column name and submit a pull request if you wanted.
Personally I'd just upgrade to 9.3.
Upvotes: 4