 'buffercache_by_type',
 9.2,
 $sql$
-select
-  (extract(epoch from now()) * 1e9)::int8 as epoch_ns,
-    SELECT       CASE WHEN relkind = 'r' THEN 'Table'   -- TODO all relkinds covered?
-                 WHEN relkind = 'i' THEN 'Index'
-                 WHEN relkind = 't' THEN 'Toast'
-                 WHEN relkind = 'm' THEN 'Materialized view'
-                 ELSE 'Other' END,
-            count(*) * 8192
-    FROM    pg_buffercache AS b, pg_class AS d
-    WHERE   d.oid = b.relfilenode
-    GROUP BY 1;
+SELECT
+  (extract(epoch from now()) * 1e9)::int8 as epoch_ns,
+  CASE
+    WHEN relkind = 'r' THEN 'Table'   -- TODO all relkinds covered?
+    WHEN relkind = 'i' THEN 'Index'
+    WHEN relkind = 't' THEN 'Toast'
+    WHEN relkind = 'm' THEN 'Materialized view'
+    ELSE 'Other'
+  END,
+  count(*) * 8192
+FROM
+  pg_buffercache AS b,
+  pg_class AS d
+WHERE
+  d.oid = b.relfilenode
+GROUP BY 
+  relkind;
 $sql$
 );
 

'buffercache_by_db',
9.2,
$sql$
select
  (extract(epoch from now()) * 1e9)::int8 as epoch_ns,
  SELECT datname,
  count(*) * 8192
FROM
  pg_buffercache AS b,

WHERE
  d.oid = b.reldatabase
GROUP BY
  datname;
$sql$
);

