manipulating anyarray columns
От | Tomas Vondra |
---|---|
Тема | manipulating anyarray columns |
Дата | |
Msg-id | 4FA54F74.8070604@fuzzy.cz обсуждение исходный текст |
Список | pgsql-general |
Hi, I have to deal with anyarray columns for the first time, and I've run into some trouble. I need to read the pg_stats.most_common_vals column, and read several items, i.e. most frequent values stored in the column. With a regular column (as for example most_common_freqs) I can do this SELECT most_common_freqs[1:3] FROM pg_stats WHERE tablename = 'pg_attribute' AND attname = 'attname'; to get the first 3 items (frequencies), but with anyarray, I can't do that - for example SELECT most_common_vals[1:3] FROM pg_stats WHERE tablename = 'pg_attribute' AND attname = 'attname'; ERROR: cannot subscript type anyarray because it is not an array I do understand that many operations are not available with anyarray as the actual type is unknown (it could be an array of arrays etc.) but why is this impossible? Surprisingly, I can do this: SELECT (string_to_array(array_to_string(most_common_vals,','),','))[1:3] FROM pg_stats WHERE tablename = 'pg_attribute' AND attname = 'attname'; which is good enough for me, but I'm curious why the simple approach does not work. Or am I missing something / using it incorrectly? Tomas
В списке pgsql-general по дате отправления: