OSDN Git Service

Fix rounding problem in dynahash.c's decision about when the target
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 21 Nov 2004 22:57:00 +0000 (22:57 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 21 Nov 2004 22:57:00 +0000 (22:57 +0000)
fill factor has been exceeded.  We usually run with ffactor == 1, but
the way the test was coded, it wouldn't split a bucket until the actual
fill factor reached 2.0, because of use of integer division.  Change
from > to >= so that it will split more aggressively when the table
starts to get full.

src/backend/utils/hash/dynahash.c

index cf4e60e..35398fb 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.56 2004/10/25 00:46:43 neilc Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.57 2004/11/21 22:57:00 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -662,7 +662,7 @@ hash_search(HTAB *hashp,
                        /* caller is expected to fill the data field on return */
 
                        /* Check if it is time to split the segment */
-                       if (++hctl->nentries / (long) (hctl->max_bucket + 1) > hctl->ffactor)
+                       if (++hctl->nentries / (long) (hctl->max_bucket + 1) >= hctl->ffactor)
                        {
                                /*
                                 * NOTE: failure to expand table is not a fatal error, it