forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf48b4f8
committed
Correct Memoize's estimated cache hit ratio calculation
As demonstrated by David Johnston, the Memoize cache hit ratio calculationwasn't quite correct.This change only affects the estimated hit ratio when the estimated numberof entries to cache is estimated not to fit inside the cache. Forexample, if we expect 2000 distinct cache key values and only expect to beable to cache 1000 of those at once due to memory constraints, with anestimate of 10000 calls, if we could store all entries then the hit ratioshould be 80% to account for the first 2000 of the 10000 calls to be acache miss due to the value not being cached yet. If we can only store1000 entries for each of the 2000 distinct possible values at once thenthe 80% should be reduced by half to make the final estimate of 40%.Previously, the calculation would have produced an estimated hit ratio of30%, which wasn't correct.Apply to master only so as not to destabilize plans in the back branches.Reported-by: David G. JohnstonDiscussion:https://postgr.es/m/CAKFQuwZEmcNk3YQo2Xj4EDUOdY6qakad31rOD1Vc4q1_s68-Ew@mail.gmail.comDiscussion:https://postgr.es/m/CAApHDvrV44LwiF4W_qf_RpbGYWSgp1kF=cZr+kTRRaALUfmXqw@mail.gmail.com1 parentb0d8f2d commitf48b4f8
1 file changed
+3
-4
lines changedLines changed: 3 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2558 | 2558 |
| |
2559 | 2559 |
| |
2560 | 2560 |
| |
2561 |
| - | |
2562 |
| - | |
| 2561 | + | |
| 2562 | + | |
2563 | 2563 |
| |
2564 |
| - | |
2565 |
| - | |
| 2564 | + | |
2566 | 2565 |
| |
2567 | 2566 |
| |
2568 | 2567 |
| |
|
0 commit comments
Comments
(0)