Re: FETCH FIRST clause WITH TIES option
Tomas Vondra <tomas.vondra@2ndquadrant.com>
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Surafel Temesgen <surafel3000@gmail.com>
Cc: David Steele <david@pgmasters.net>, Michael Paquier <michael@paquier.xyz>, Robert Haas <robertmhaas@gmail.com>, andrew@tao11.riddles.org.uk, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2019-04-03T19:02:57Z
Lists: 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
Commits
-
Support FETCH FIRST WITH TIES
- 357889eb17bb 13.0 landed