Re: FETCH FIRST clause WITH TIES option - Mailing list pgsql-hackers

From Tomas Vondra
Subject Re: FETCH FIRST clause WITH TIES option
Date
Msg-id 20190403190257.44fxttkpo4yopp3l@development
Whole thread Raw
In response to Re: Re: FETCH FIRST clause WITH TIES option  (Surafel Temesgen <surafel3000@gmail.com>)
Responses Re: FETCH FIRST clause WITH TIES option
List pgsql-hackers
Hi,

Unfortunately this got broken again, this time by aef65db676 :-(

I've tried to fix the merge conflict (essentially by moving some of the
code to adjust_limit_rows_costs(), but I'm wondering if the code added to
create_limit_path is actually correct

    if (count_est != 0)
    {
        double        count_rows;

        if (count_est > 0)
            count_rows = (double) count_est;
        else
            count_rows = clamp_row_est(subpath->rows * 0.10);

        if (limitOption == WITH_TIES)
        {
            ...
            count_rows = Max(avgGroupSize, count_est + (...));
        }
        ...
    }

Firstly, this seriously needs some comment explaining why we do this. But
more importantly - shouldn't it really be

    count_rows = Max(avgGroupSize, count_rows + (...));

instead of using count_est again (which might easily be -1 anyway)?


regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




pgsql-hackers by date:

Previous
From: Nikolay Shaplov
Date:
Subject: Re: [PATCH] src/test/modules/dummy_index -- way to test reloptions from inside of access method
Next
From: Tom Lane
Date:
Subject: Re: FETCH FIRST clause WITH TIES option