Re: Improve handling of pg_stat_statements handling of bind "IN" variables

Поиск
Список
Период
Сортировка
От Dmitry Dolgov
Тема Re: Improve handling of pg_stat_statements handling of bind "IN" variables
Дата
Msg-id CA+q6zcVc8gzGvdWQuYHy-m3x+vpCV7OEyirLut4QT5Rq3nfLnQ@mail.gmail.com
обсуждение исходный текст
Ответ на Improve handling of pg_stat_statements handling of bind "IN" variables  (Pavel Trukhanov <pavel.trukhanov@gmail.com>)
Ответы Re: Improve handling of pg_stat_statements handling of bind "IN" variables  (Pavel Trukhanov <pavel.trukhanov@gmail.com>)
Список pgsql-hackers
> On Thu, Jun 13, 2019 at 1:38 PM Pavel Trukhanov <pavel.trukhanov@gmail.com> wrote:
>
> Hi Hackers
>
> I would like to embark on a journey to try to implement this issue I
> found on TODO list –
> https://www.postgresql.org/message-id/flat/CAM3SWZSpdPB3uErnXWMt3q74y0r%2B84ZsOt2U3HKKes_V7O%2B0Qg%40mail.gmail.com
> In short: pgss distinguishes "SELECT * WHERE id IN (1, 2)" and "SELECT
> * WHERE id IN (1, 2, 3)" as two separate queryId's, resulting in
> separate entries in pgss. While in practice in most cases it should be
> considered as the same thing.
>
> Though it was added in TODO by Bruce Momjian some time ago, I
> personally have been annoyed by this issue, because we use pgss as a
> data source in our monitoring system okmeter.io – so we've been using
> some work arounds for this in our system.

Thanks! One more time stumbled upon it just now, so I agree it would be nice.

> 1. ArrayExpr
> ArrayExpr is used to represent not only "IN" clauses, but also for
> example "SELECT ARRAY[1, 2, 3]" and maybe some other cases I didn't
> think of.
> That brings the question whether "IN (...)" should be handled
> separately from actual usage of ARRAY.

If I understand correctly, "IN (...)" is reprecented by A_Expr with kind
AEXPR_IN, and only in transformAExprIn converted to ArrayExpr if possible. So
probably it doesn't makes sense to introduce another one.

> For example "SELECT ARRAY[1, 2, a] FROM table" and "SELECT ARRAY[b]
> FROM table" might end up in the same pgss entry.

What are a, b here, parameters?

> 3 Tests in pgss.sql/out and Vars
> I would like someone to point me in a direction of how could I
> implement a test that will query
> "SELECT * FROM test WHERE a IN ($1, $2, $3, ...)" with params, not
> consts

Wouldn't a prepared statement work? It will create an ArrayExpr with Params
inside.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Masahiko Sawada
Дата:
Сообщение: Re: pg_upgrade: Improve invalid option handling
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: PG 12 draft release notes