Another approach is to try to fix pg_statistic to avoid the problem by not doing I/O conversions. For scalar datatypes (those that have associated array types) it'd be probably be feasible to store the histogram and most-common-value arrays as arrays of the datatype itself, not arrays of text; that should be a win for performance as well as avoiding risky conversions. I am not sure what to do about columns that have datatypes without matching array types, though (that would include array columns and domains, IIRC). Maybe use array of bytea to hold the internal representation of the type?
ISTM that the best (if not the only feasible) approach is using array of bytea to hold the internal representation of the type.
Joe
---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster