postgresql_16:9.6.18.5 Statistics
PostgreSQL 16 > Appendixes > Additional Supplied Modules and Extensions > hstore — hstore key/value datatype > Statistics
The hstore type, because of its intrinsic liberality, could contain a lot of different keys. Checking for valid keys is the task of the application. The following examples demonstrate several techniques for checking keys and obtaining statistics.
Simple example: SELECT * FROM each('aaa=>bq, b=>NULL, ""=>1');
Using a table: CREATE TABLE stat AS SELECT (each(h)).key, (each(h)).value FROM testhstore;
Online statistics: SELECT key, count(*) FROM (SELECT (each(h)).key FROM testhstore) AS stat GROUP BY key ORDER BY count DESC, key; key | count -----------+------- line | 883 query | 207 pos | 203 node | 202 space | 197 status | 195 public | 194 title | 190 org | 189 ...................