|
122 | 122 | #define DEF_SEGSIZE 256
|
123 | 123 | #define DEF_SEGSIZE_SHIFT 8 /* must be log2(DEF_SEGSIZE) */
|
124 | 124 | #define DEF_DIRSIZE 256
|
125 |
| -#define DEF_FFACTOR 1 /* default fill factor */ |
126 | 125 |
|
127 | 126 | /* Number of freelists to be used for a partitioned hash table. */
|
128 | 127 | #define NUM_FREELISTS 32
|
@@ -191,7 +190,6 @@ struct HASHHDR
|
191 | 190 | Size keysize; /* hash key length in bytes */
|
192 | 191 | Size entrysize; /* total user element size in bytes */
|
193 | 192 | long num_partitions; /* # partitions (must be power of 2), or 0 */
|
194 |
| - long ffactor; /* target fill factor */ |
195 | 193 | long max_dsize; /* 'dsize' limit if directory is fixed size */
|
196 | 194 | long ssize; /* segment size --- must be power of 2 */
|
197 | 195 | int sshift; /* segment shift = log2(ssize) */
|
@@ -497,8 +495,6 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
|
497 | 495 | /* ssize had better be a power of 2 */
|
498 | 496 | Assert(hctl->ssize == (1L << hctl->sshift));
|
499 | 497 | }
|
500 |
| - if (flags & HASH_FFACTOR) |
501 |
| - hctl->ffactor = info->ffactor; |
502 | 498 |
|
503 | 499 | /*
|
504 | 500 | * SHM hash tables have fixed directory size passed by the caller.
|
@@ -603,8 +599,6 @@ hdefault(HTAB *hashp)
|
603 | 599 |
|
604 | 600 | hctl->num_partitions = 0; /* not partitioned */
|
605 | 601 |
|
606 |
| - hctl->ffactor = DEF_FFACTOR; |
607 |
| - |
608 | 602 | /* table has no fixed maximum size */
|
609 | 603 | hctl->max_dsize = NO_MAX_DSIZE;
|
610 | 604 |
|
@@ -670,11 +664,10 @@ init_htab(HTAB *hashp, long nelem)
|
670 | 664 | SpinLockInit(&(hctl->freeList[i].mutex));
|
671 | 665 |
|
672 | 666 | /*
|
673 |
| - * Divide number of elements by the fill factor to determine a desired |
674 |
| - * number of buckets. Allocate space for the next greater power of two |
675 |
| - * number of buckets |
| 667 | + * Allocate space for the next greater power of two number of buckets, |
| 668 | + * assuming a desired maximum load factor of 1. |
676 | 669 | */
|
677 |
| - nbuckets = next_pow2_int((nelem - 1) / hctl->ffactor + 1); |
| 670 | + nbuckets = next_pow2_int(nelem); |
678 | 671 |
|
679 | 672 | /*
|
680 | 673 | * In a partitioned table, nbuckets must be at least equal to
|
@@ -733,7 +726,6 @@ init_htab(HTAB *hashp, long nelem)
|
733 | 726 | "DIRECTORY SIZE ", hctl->dsize,
|
734 | 727 | "SEGMENT SIZE ", hctl->ssize,
|
735 | 728 | "SEGMENT SHIFT ", hctl->sshift,
|
736 |
| - "FILL FACTOR ", hctl->ffactor, |
737 | 729 | "MAX BUCKET ", hctl->max_bucket,
|
738 | 730 | "HIGH MASK ", hctl->high_mask,
|
739 | 731 | "LOW MASK ", hctl->low_mask,
|
@@ -761,7 +753,7 @@ hash_estimate_size(long num_entries, Size entrysize)
|
761 | 753 | elementAllocCnt;
|
762 | 754 |
|
763 | 755 | /* estimate number of buckets wanted */
|
764 |
| - nBuckets = next_pow2_long((num_entries - 1) / DEF_FFACTOR + 1); |
| 756 | + nBuckets = next_pow2_long(num_entries); |
765 | 757 | /* # of segments needed for nBuckets */
|
766 | 758 | nSegments = next_pow2_long((nBuckets - 1) / DEF_SEGSIZE + 1);
|
767 | 759 | /* directory entries */
|
@@ -804,7 +796,7 @@ hash_select_dirsize(long num_entries)
|
804 | 796 | nDirEntries;
|
805 | 797 |
|
806 | 798 | /* estimate number of buckets wanted */
|
807 |
| - nBuckets = next_pow2_long((num_entries - 1) / DEF_FFACTOR + 1); |
| 799 | + nBuckets = next_pow2_long(num_entries); |
808 | 800 | /* # of segments needed for nBuckets */
|
809 | 801 | nSegments = next_pow2_long((nBuckets - 1) / DEF_SEGSIZE + 1);
|
810 | 802 | /* directory entries */
|
@@ -975,7 +967,7 @@ hash_search_with_hash_value(HTAB *hashp,
|
975 | 967 | * order of these tests is to try to check cheaper conditions first.
|
976 | 968 | */
|
977 | 969 | if (!IS_PARTITIONED(hctl) && !hashp->frozen &&
|
978 |
| - hctl->freeList[0].nentries / (long) (hctl->max_bucket + 1) >= hctl->ffactor && |
| 970 | + hctl->freeList[0].nentries > (long) (hctl->max_bucket + 1) && |
979 | 971 | !has_seq_scans(hashp))
|
980 | 972 | (void) expand_table(hashp);
|
981 | 973 | }
|
|
0 commit comments