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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to