pg_stat_statements query normalization, and the 'in' operator

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

pg_stat_statements query normalization, and the 'in' operator

unixway.drive
Hello there,

Given the following list of queries:

   create table foo (id serial, bar integer);
   select * from foo where id in (1);
   select * from foo where id in (2,3);
   select * from foo where id in (1,3,5);
   select * from foo where id in (select id from foo);

would it be possible to have first three select queries to be normalized
into a single one so that 'select query from pg_stat_statements' returns
something like:

   select * from foo where id in (...);
   select * from foo where id in (select id from foo);
   (2 rows)

instead of:

   select * from foo where id in (?,?);
   select * from foo where id in (?,?,?);
   select * from foo where id in (?);
   select * from foo where id in (select id from foo);
   (4 rows)

?


--
Sent via pgsql-hackers mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: pg_stat_statements query normalization, and the 'in' operator

Tom Lane-2
[hidden email] writes:
> Given the following list of queries:

>    create table foo (id serial, bar integer);
>    select * from foo where id in (1);
>    select * from foo where id in (2,3);
>    select * from foo where id in (1,3,5);
>    select * from foo where id in (select id from foo);

> would it be possible to have first three select queries to be normalized
> into a single one so that 'select query from pg_stat_statements' returns
> something like:

>    select * from foo where id in (...);
>    select * from foo where id in (select id from foo);

Wouldn't recommend holding your breath for that.  But you could do the
same conversion on the client side that the parser would do anyway:

select * from foo where id = any ('{1,3,5}'::integer[]);

                        regards, tom lane


--
Sent via pgsql-hackers mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Previous Thread Next Thread
Loading...