Re: Prepare Statement VS Literal Values

2021-04-12 Thread Virendra Kumar
$1; > PREPARE > postgres=# explain analyze execute qq('AB1234'); >                                           QUERY PLAN > --- >  Seq Scan on t  (cost=0.00..224.00 rows=50 width=21) (a

Re: Prepare Statement VS Literal Values

2021-04-11 Thread Ravi Krishna
This looks like early vs late binding problem, also seen in  other products.  When you prepare the sql, the optimizer has no way of knowing the values which is going to be supplied in future.  So it is possible that at the time of preparing PG settles on a plan and uses it for all values, regardles

Prepare Statement VS Literal Values

2021-04-11 Thread Virendra Kumar
Hi Team, I am struggling a lot on this for at least 3-4 queries. When I run explain analyze using literal values the query takes good plan but as soon as I use bind variable using the prepare statement it is going for toss and the same query is taking a lot of time. testdb=# select version();