Optimise som_page_handler for SOMs with many tc_config columns

Rather than SELECT * FROM tc_config_tbl and then calling List.dedup and List.sort on each column, we do individual queries for the values in each column.
Use the new materialized view measurements_distinct to speed up queries on distinct values on the measurements table.