parameterized limit statements - Mailing list pgsql-hackers

From Merlin Moncure
Subject parameterized limit statements
Date
Msg-id 6EE64EF3AB31D5448D0007DD34EEB3417DD7EC@Herge.rcsinc.local
Whole thread Raw
Responses Re: parameterized limit statements
List pgsql-hackers
I noticed your 8/18 commit to address an issue I raised regarding
parameterized limit statements.  Specifically, prepared statements with
a variable limit would tend to revert to bitmap or seqscan.

I check out cvs tip and am still getting that behavior :(.  So, I had a
look at createplan.c to see what was going on.  Inside makelimit, there
is:

if (count_est != 0)
{double        count_rows;
if (count_est > 0)    count_rows = (double) count_est;else    count_rows = clamp_row_est(lefttree->plan_rows * 0.10);if
(count_rows> plan->plan_rows)    count_rows = plan->plan_rows;if (plan->plan_rows > 0)    plan->total_cost =
plan->startup_cost+        (plan->total_cost - plan->startup_cost)        * count_rows /
plan->plan_rows;plan->plan_rows= count_rows;if (plan->plan_rows < 1)    plan->plan_rows = 1;  
}

Is this correct? plan_rows is assigned (from count_rows) after it is
checked to determine cost.  If this is correct, would you like a test
cast demonstrating the behavior?

Merlin


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Another pgindent gripe
Next
From: Tom Lane
Date:
Subject: Re: parameterized limit statements