I do not have an explanation from the patch yet, but I have a test
that appears to show unexpected results. I only tested a few datatypes,
but from what I observe, some merge as expected and others do not;
i.e. int columns merge correctly but bigint do not.
"""
show pg_stat_statements.query_id_const_merge ;
create table foo (col_int int, col_smallint smallint, col_bigint
bigint, col_float float, col_text text, col_varchar varchar);
select from foo where col_int in (1, 2, 3);
select from foo where col_int in (1, 2, 3, 4);
select from foo where col_int in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
select from foo where col_smallint in (1, 2, 3);
select from foo where col_smallint in (1, 2, 3, 4);
select from foo where col_bigint in (1, 2, 3);
select from foo where col_bigint in (1, 2, 3, 4);
select from foo where col_bigint in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
select from foo where col_float in (1, 2, 3);
select from foo where col_float in (1, 2, 3, 4);
select query, queryid, calls from pg_stat_statements where query like
'select from foo where%' order by 1 desc ;
"""
postgres=# show pg_stat_statements.query_id_const_merge ;
pg_stat_statements.query_id_const_merge
-----------------------------------------
on
(1 row)
....
.......
..........
postgres=# select query, queryid, calls from pg_stat_statements where
query like 'select from foo where%' order by 1 desc ;
query
| queryid | calls
-------------------------------------------------------------------------------+----------------------+-------
select from foo where col_smallint in (...)
| -2065640271713949220 | 2
select from foo where col_int in (...)
| 2911888824129257715 | 3
select from foo where col_float in ($1, $2, $3, $4)
| -6847088148705359339 | 1
select from foo where col_float in ($1, $2, $3)
| 1631437678183488606 | 1
select from foo where col_bigint in ($1, $2, $3, $4, $5, $6, $7, $8,
$9, $10) | 3174053975478689499 | 1
select from foo where col_bigint in ($1, $2, $3, $4)
| -5236067031911646410 | 1
select from foo where col_bigint in ($1, $2, $3)
| -5529594240898645457 | 1
(7 rows)
---
Sami