PgHero
No long running queries
Connections healthy 7
Vacuuming healthy
No columns near integer overflow
No invalid indexes or constraints
No duplicate indexes
No suggested indexes
4 slow queries

Slow Queries

Slow queries take 20 ms or more on average and have been called at least 100 times.

Explain queries to see where to add indexes.

Total Time Average Time Calls
72 min 46% 29 ms 147,754 payments
SELECT invoices.method_id, methods.method_name, invoices.system_id FROM invoices JOIN methods ON methods.id = invoices.method_id WHERE invoices.project_id = $1 AND ext_user_id = $2 AND is_finished = $3 AND is_success = $4 ORDER by created_at DESC
57 min 36% 23 ms 147,754 payments
SELECT methods.id, method_name, count(*)
  FROM invoices
  JOIN methods ON invoices.method_id = methods.id
  WHERE created_at > NOW() - $2::interval AND invoices.project_id = $1
  GROUP by methods.id, method_name
  ORDER by count(*) DESC
  limit $3
1 min 0.9% 100 ms 833 payments
SELECT systems.name,
  date((created_at) AT TIME ZONE $2) as date,
  SUM(amount/$3) as raw_amount,
  SUM(recieved_amount) as amount,
  currency.title as currency
  FROM invoices
  JOIN systems ON systems.id = invoices.system_id
  JOIN currency on currency.id = recieved_currency
  WHERE project_id = $1 AND is_finished = $4
  GROUP by systems.name, date((created_at) AT TIME ZONE 'Europe/Moscow'), currency.title
  ORDER by date((created_at) AT TIME ZONE 'Europe/Moscow') DESC
1 min 0.4% 38 ms 987 payments
WITH query_stats AS ( SELECT LEFT(query, $1) AS query, queryid AS query_hash, rolname AS user, ((total_plan_time + total_exec_time) / $2 / $3) AS total_minutes, ((total_plan_time + total_exec_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 calls > $4 AND pg_database.datname = current_database() ) SELECT query, query_hash, query_stats.user, total_minutes, average_time, calls, total_minutes * $5 / (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 $6 /*pghero*/