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

Commitae0c8d0

Browse files
committed
Remove "fuzzy comparison" logic in qsort comparison function for
choose_bitmap_and(). It was way too fuzzy --- per comment, it was meant to be1% relative difference, but was actually coded as 0.01 absolute difference,thus causing selectivities of say 0.001 and 0.000000000001 to be treated asequal. I believe this thinko explains Maxim Boguk's recent complaint. Whilewe could change it to a relative test coded like compare_fuzzy_path_costs(),there's a bigger problem here, which is that any fuzziness at all renders thecomparison function non-transitive, which could confuse qsort() to the pointof delivering completely wrong results. So forget the whole thing and justdo an exact comparison.
1 parentca9d503 commitae0c8d0

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.207 2006/06/06 17:59:57 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.208 2006/06/07 17:08:07 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -674,20 +674,18 @@ bitmap_path_comparator(const void *a, const void *b)
674674
Costbcost;
675675
Selectivityaselec;
676676
Selectivitybselec;
677-
Selectivitydiff;
678677

679678
cost_bitmap_tree_node(pa,&acost,&aselec);
680679
cost_bitmap_tree_node(pb,&bcost,&bselec);
681680

682681
/*
683-
*Since selectivities areoften pretty crude, don't put blind faith
684-
*in them; if the selectivities are within 1% of being the same, treat
685-
*them as equal and sort by cost instead.
682+
*If selectivities arethe same, sort by cost. (Note: there used to be
683+
*logic here to do "fuzzy comparison", but that's a bad idea because it
684+
*fails to be transitive, which will confuse qsort terribly.)
686685
*/
687-
diff=aselec-bselec;
688-
if (diff<-0.01)
686+
if (aselec<bselec)
689687
return-1;
690-
if (diff>0.01)
688+
if (aselec>bselec)
691689
return1;
692690

693691
if (acost<bcost)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp