Search code examples
sqlpostgresqlhstore

Get the per-row number of keys of hstore data in postgresql


I have a hstore column in my postgresql database. Each row of the database has a different number of keys/values in the hstore-column. How can i get the number of keys/values for each row?


Solution

  • select hstore_column, 
           array_length(akeys(hstore_column), 1) as num_keys
    from the_table