clamp_row_est avoid infinite

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: clamp_row_est avoid infinite
Date: 2024-04-23 03:22:17
Message-ID: CACJufxHVenbVW=gX=LQCwB0-tEmHh6OVx1DhLb7OLZdhLskp-w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.

/*
* clamp_row_est
* Force a row-count estimate to a sane value.
*/
double
clamp_row_est(double nrows)
{
/*
* Avoid infinite and NaN row estimates. Costs derived from such values
* are going to be useless. Also force the estimate to be at least one
* row, to make explain output look better and to avoid possible
* divide-by-zero when interpolating costs. Make it an integer, too.
*/
if (nrows > MAXIMUM_ROWCOUNT || isnan(nrows))
nrows = MAXIMUM_ROWCOUNT;
else if (nrows <= 1.0)
nrows = 1.0;
else
nrows = rint(nrows);

return nrows;
}

The comments say `Avoid infinite and NaN`
but actually we only avoid NaN.

Do we need to add isinf(nrows)?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2024-04-23 03:37:23 Re: promotion related handling in pg_sync_replication_slots()
Previous Message Peter Smith 2024-04-23 03:06:03 Re: logicalrep_worker_launch -- counting/checking the worker limits