2017-08-10 90 views
1

我們有一個在版本9.6.1queryid列pg_stat_statements表中缺少

運行升級時我們pghero安裝2.0.2我們購置pghero失敗的最新版本的Heroku Postgres數據庫無法在pg_stat_statements表中查找queryid列。

安裝了pg_stat_statements擴展。

2017-08-10T09:54:44.002042+00:00 app[web.1]: Completed 500 Internal Server Error in 274ms (ActiveRecord: 186.1ms) 
2017-08-10T09:54:44.004012+00:00 app[web.1]: 
2017-08-10T09:54:44.004048+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::UndefinedColumn: ERROR: column "queryid" does not exist 
2017-08-10T09:54:44.004050+00:00 app[web.1]: LINE 1: ...ry_stats AS (SELECT LEFT(query, 10000) AS query, queryid AS... 
2017-08-10T09:54:44.004051+00:00 app[web.1]:               ^
2017-08-10T09:54:44.004052+00:00 app[web.1]: HINT: Perhaps you meant to reference the column "pg_stat_statements.query". 
2017-08-10T09:54:44.004055+00:00 app[web.1]: : WITH query_stats AS (SELECT LEFT(query, 10000) AS query, queryid AS query_hash, rolname AS user, (total_time/1000/60) AS total_minutes, (total_time/calls) AS average_time, calls FROM pg_stat_statements INNER JOIN pg_database ON pg_database.oid = pg_stat_statements.dbid INNER JOIN pg_roles ON pg_roles.oid = pg_stat_statements.userid WHERE pg_database.datname = current_database()) SELECT query, query_hash, query_stats.user, total_minutes, average_time, calls, total_minutes * 100.0/(SELECT SUM(total_minutes) FROM query_stats) AS total_percent, (SELECT SUM(total_minutes) FROM query_stats) AS all_queries_total_minutes FROM query_stats ORDER BY "total_minutes" DESC LIMIT 100): 

回答

0

事實證明,升級heroku上的postgres版本並不一定會更新擴展到最新版本。

通過運行

ALTER EXTENSION pg_stat_statements UPDATE; 

更新擴展固定的問題。