Sha256: dae490e88ebf6a5d6e5d100c15b123e58a0bca539ec2f52e712cfd4fab6abe29

Contents?: true

Size: 503 Bytes

Versions: 30

Compression:

Stored size: 503 Bytes

Contents

/* Calculates your cache hit rate for reading tables */

SELECT
  relname AS name,
  heap_blks_hit AS buffer_hits,
  heap_blks_read AS block_reads,
  heap_blks_hit + heap_blks_read AS total_read,
  CASE (heap_blks_hit + heap_blks_read)::float
    WHEN 0 THEN 'Insufficient data'
    ELSE (heap_blks_hit / (heap_blks_hit + heap_blks_read)::float)::text
  END ratio
FROM
  pg_statio_user_tables
WHERE
  schemaname = '%{schema}'
ORDER BY
  heap_blks_hit / (heap_blks_hit + heap_blks_read + 1)::float DESC;

Version data entries

30 entries across 30 versions & 1 rubygems

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