[prev] 21 [next]

Clock-sweep Replacement Strategy

PostgreSQL page replacement strategy: clock-sweep
  • treat buffer pool as circular list of buffer slots
  • NextVictimBuffer holds index of next possible evictee
  • if page is pinned or "popular", leave it
    • usage_count implements "popularity/recency" measure
    • incremented on each access to buffer (up to small limit)
    • decremented each time considered for eviction
  • increment NextVictimBuffer and try again (wrap at end)
For specialised kinds of access (e.g. sequential scan), can allocate a private "buffer ring" with different replacement strategy.