From: pgsql-general-owner@xxxxxxxxxxxxxx [mailto:pgsql-general-owner@xxxxxxxxxxxxxx] On Behalf Of - - Here are the EXPLAIN ANALYZE outputs: The filter_hash index uses a “character(n)” data type – the ::bpchar. The second query is of unknown type and thus is converted to “character” and then used in the index. The first query use a function that outputs a “text”. Since the output type is known the left-side of the equals is casted to that known type. Since the index is one the “character” version of the filter_hash but the comparison requires a “text” version the index cannot be used. You would need to manually cast the result of the md5 function call to “character” in order to get the index usage; or convert the filter_hash column to text, the latter option probably being preferred. It is not a bug, in cases of uncertainty the types of the value and the indexed field must be the same, but it could possibly be more user-friendly. I’ll leave it to other to comment on whether this is different in more recent versions. Text-character are binary compatible and so it is not be unreasonable to assume, like you did, that indexes of one should be usable by the other. David J. |