PostgreSQL Index Usage Analysis

前端 未结 9 1646
伪装坚强ぢ
伪装坚强ぢ 2021-01-29 17:43

Is there a tool or method to analyze Postgres, and determine what missing indexes should be created, and which unused indexes should be removed? I have a little experience doing

9条回答
  •  伪装坚强ぢ
    2021-01-29 18:04

    CREATE EXTENSION pgstattuple; 
    CREATE TABLE test(t INT); 
    INSERT INTO test VALUES(generate_series(1, 100000)); 
    SELECT * FROM pgstatindex('test_idx'); 
    
    version            | 2 
    tree_level         | 2 
    index_size         | 105332736 
    root_block_no      | 412 
    internal_pages     | 40 
    leaf_pages         | 12804 
    empty_pages        | 0 
    deleted_pages      | 13 
    avg_leaf_density   | 9.84 
    leaf_fragmentation | 21.42 
    

提交回复
热议问题