possibly to automatic detection of bad variable types in plans?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: possibly to automatic detection of bad variable types in plans?
Date: 2018-03-20 08:06:02
Message-ID: CAFj8pRC7faA=FRBKG3hYrBQGU21YA2LBh5mXDOS-wHkkSg2Gqg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

I have a talk with Alex Stanev about known issue that block indexes - bad
param types

postgres=# do $$
declare _id numeric = 777722;
begin
perform * from bigtable where a = _id;
end;
$$;
DO
Time: 108,775 ms
postgres=# do $$
declare _id numeric = 777722;
begin
perform * from bigtable where a = _id;
end;
$$;
DO
Time: 106,111 ms
postgres=# do $$
declare _id int = 777722;
begin
perform * from bigtable where a = _id;
end;
$$;
DO
Time: 1,522 ms
postgres=# do $$
declare _id numeric = 777722;
begin
perform * from bigtable where a = _id;
end;
$$;
DO
Time: 108,287 ms

https://github.com/okbob/plpgsql_check/issues/32

Is possible to write a extension, that raise warning so index is not
possible due bad parameter type, or so cast will be performed on every row?

It can be started like autoexplain.

Regards

Pavel

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Gierth 2018-03-20 08:38:45 Re: PostgreSQL 10: Segmentation fault when using GROUPING SETS with all unsortable columns
Previous Message Meenatchi Sandanam 2018-03-20 08:04:02 Re: PostgreSQL opens all the indexes of a relation for every Query during Planning Time?