Re: pg_stat_statements and "IN" conditions - Mailing list pgsql-hackers

From Sami Imseih
Subject Re: pg_stat_statements and "IN" conditions
Date
Msg-id CAA5RZ0v6h-ohXTV6wWsHN1TKW5XHOkfu+0TpTKXauYfYfhPaeg@mail.gmail.com
Whole thread Raw
In response to Re: pg_stat_statements and "IN" conditions  (Sami Imseih <samimseih@gmail.com>)
Responses Re: pg_stat_statements and "IN" conditions
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Proposal: "query_work_mem" GUC, to distribute working memory to the query's individual operators
Next
From: Matthias van de Meent
Date:
Subject: Re: Expanding HOT updates for expression and partial indexes