guides/Heroku.md in pghero-1.1.0 vs guides/Heroku.md in pghero-1.1.1
- old
+ new
@@ -19,9 +19,38 @@
For databases outside of Heroku, query stats can be enabled from the dashboard.
If you run into issues, [view the guide](Query-Stats.md).
+## Historical Query Stats
+
+To track query stats over time, create a table to store them.
+
+```sql
+CREATE TABLE "pghero_query_stats" ("id" serial primary key, "database" text, "query" text, "total_time" float, "calls" bigint, "captured_at" timestamp)
+CREATE INDEX "index_pghero_query_stats_on_database_and_captured_at" ON "pghero_query_stats" ("database", "captured_at")
+```
+
+This table can be in the current database or another database. If another database, run:
+
+```sh
+heroku config:set PGHERO_STATS_DATABASE_URL=...
+```
+
+Schedule the task below to run every 5 minutes.
+
+```sh
+rake pghero:capture_query_stats
+```
+
+Or with a scheduler like Clockwork, use:
+
+```ruby
+PgHero.capture_query_stats
+```
+
+After this, a time range slider will appear on the Queries tab.
+
## System Stats
CPU usage is available for Amazon RDS. Add these variables to your environment:
```sh