While putting PostgreSQL 9.2 through it’s paces, I noticed some behavior that was eerily familiar.
Back in January of 2006, Peter Zaitsev opened a bug against MySQL 4.1 that complained of a comparison of an out-of-range constant triggering a key lookup (later distilled to a feature request to “statically evaluate predicates using implicit type constraints”). Let me explain. Assume the following table:
postgres=# \d t1
Table "public.t1"
Column | Type | Modifiers
--------+---------------+-----------
id | character(10) | not null
How would we expect the following query to be handled
postgres=# select count(*) from t1 WHERE id = 'aoeuaoeuaoeu';
-[ RECORD 1 ]
count | 0
More »