Sha256: f58a191d693e3b49cf23f54bae09b2a6786a08b62f8f2884b2f20afdae6ed030

Contents?: true

Size: 570 Bytes

Versions: 57

Compression:

Stored size: 570 Bytes

Contents

/* Calculates percentages of relations buffered in database share buffer */

SELECT
  c.relname,
  pg_size_pretty(count(*) * 8192) AS buffered,
  round(100.0 * count(*) / (SELECT setting FROM pg_settings WHERE name = 'shared_buffers')::integer, 1) AS buffer_percent,
  round(100.0 * count(*) * 8192 / pg_table_size(c.oid), 1) AS percent_of_relation
FROM pg_class c
INNER JOIN pg_buffercache b ON b.relfilenode = c.relfilenode
INNER JOIN pg_database d ON (b.reldatabase = d.oid AND d.datname = current_database())
GROUP BY c.oid,c.relname
ORDER BY 3 DESC
LIMIT %{limit};

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
ruby-pg-extras-5.5.1 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.5.0 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.4.5 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.4.4 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.4.3 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.4.2 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.4.1 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.4.0 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.3.1 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.3.0 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.2.5 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.2.4 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.2.3 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.2.2 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.2.1 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.2.0 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.1.0 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-5.0.0 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-4.13.0 lib/ruby_pg_extras/queries/buffercache_stats.sql
ruby-pg-extras-4.12.2 lib/ruby_pg_extras/queries/buffercache_stats.sql