Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7177bba

Browse files
committed
A little further tweaking of the range-query selectivity logic:
to avoid undue sensitivity to roundoff error, believe that a zeroor slightly negative range estimate should represent a smallpositive selectivity, rather than falling back on a generic defaultestimate.
1 parent6d79d60 commit7177bba

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

‎src/backend/optimizer/path/clausesel.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.32 2000/03/2300:58:36 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.33 2000/03/2323:35:47 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -186,20 +186,32 @@ clauselist_selectivity(Query *root,
186186
/* Successfully matched a pair of range clauses */
187187
Selectivitys2=rqlist->hibound+rqlist->lobound-1.0;
188188

189-
if (s2>0.0)
190-
{
191-
/* All our hard work has paid off! */
192-
s1 *=s2;
193-
}
194-
else
189+
/*
190+
* A zero or slightly negative s2 should be converted into a
191+
* small positive value; we probably are dealing with a very
192+
* tight range and got a bogus result due to roundoff errors.
193+
* However, if s2 is very negative, then we probably have
194+
* default selectivity estimates on one or both sides of the
195+
* range. In that case, insert a not-so-wildly-optimistic
196+
* default estimate.
197+
*/
198+
if (s2 <=0.0)
195199
{
196-
/* One or both is probably a default estimate,
197-
* so supply a default estimate for the selectivity
198-
* of the range query. We rather optimistically assume
199-
* that the range is tight...
200-
*/
201-
s1 *=0.01;
200+
if (s2<-0.01)
201+
{
202+
/* No data available --- use a default estimate that
203+
* is small, but not real small.
204+
*/
205+
s2=0.01;
206+
}
207+
else
208+
{
209+
/* It's just roundoff error; use a small positive value */
210+
s2=1.0e-10;
211+
}
202212
}
213+
/* Merge in the selectivity of the pair of clauses */
214+
s1 *=s2;
203215
}
204216
else
205217
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp