对PostgreSQL中bufmgr.c 的BgBufferSync的静态变量学习 --prev_strategy_buf_id

开始

复制代码
bool                
BgBufferSync(void)                
{                
    ……            
    /*            
     * Information saved between calls so we can determine the strategy            
     * point's advance rate and avoid scanning already-cleaned buffers.            
     */            
    static           bool          saved_info_valid = false;            
    static           int        prev_strategy_buf_id;    
    static          uint32         prev_strategy_passes;    
    static          int        next_to_clean;    
    static     uint32     next_passes;  
                
    /* Moving averages of allocation rate and clean-buffer density */            
    static     float     smoothed_alloc = 0;    
    static     float     smoothed_density = 10.0;    
                
    ……         
                
    if (saved_info_valid)            
    {            
        ……        
        strategy_delta = strategy_buf_id - prev_strategy_buf_id;        
        strategy_delta += (long) passes_delta *NBuffers;        
        ……     
    }            
    else            
    {            
        ……        
    }            
    
fprintf(stderr,"before saving, prev_strategy_buf_id is %d \n", prev_strategy_buf_id);
/* Update saved info for next time */ prev_strategy_buf_id = strategy_buf_id; prev_strategy_passes = strategy_passes; saved_info_valid = true; …… fprintf(stderr,"prev_strategy_buf_id is %d \n", prev_strategy_buf_id); /* Return true if OK to hibernate */ return (bufs_to_lap == 0 && recent_alloc == 0); }
复制代码

执行的结果显示,即使我用psql 变更了某行的值,直到最后,prev_strategy_buf_id 的值也没有发生根本性的变化。

复制代码
[postgres@localhost bin]$ ./postgres -D /usr/local/pgsql/data        
LOG:  database system was shut down at 2012-11-02 15:30:38 CST        
saved_info_valid false.        
before saving,prev_strategy_buf_id is: 0        
prev_strategy_buf_id is 0         
LOG:  autovacuum launcher started        
LOG:  database system is ready to accept connections        
before saving,prev_strategy_buf_id is: 0        
prev_strategy_buf_id is 0         
before saving,prev_strategy_buf_id is: 0        
prev_strategy_buf_id is 0         
before saving,prev_strategy_buf_id is: 0        
prev_strategy_buf_id is 0         
before saving,prev_strategy_buf_id is: 0        
prev_strategy_buf_id is 0         
before saving,prev_strategy_buf_id is: 0        
prev_strategy_buf_id is 0         
        
……        
        
        
before saving,prev_strategy_buf_id is: 0        
prev_strategy_buf_id is 0         
LOG:  received fast shutdown request        
LOG:  aborting any active transactions        
LOG:  autovacuum launcher shutting down        
LOG:  shutting down        
LOG:  database system is shut down        
[postgres@localhost bin]$         
复制代码






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值