Java开发人员眼中的PostgreSQL索引运行状况

嘿。


我叫Vanya,我是Java开发人员。碰巧我在PostgreSQL上工作很多-我参与了数据库的调优,结构的优化,性能的提高以及在周末玩一些DBA。


最近,我整理了微服务中的几个数据库,并编写了pg-index-health java库,该有助于这项工作,节省我的时间并有助于避免开发人员犯的一些常见错误。关于这个库的将在今天进行讨论。



免责声明


我正在使用的PostgreSQL的主要版本是10。我使用的所有SQL查询也会在第11版上进行检查。支持的最低版本是9.6。


背景


: . , , . temp_file_limit. … , , , .



, Postgres, , , … . , maintenance_work_mem, temp_file_limit, statement_timeout lock_timeout.


maintenance_work_mem 64 , temp_file_limit - 2 – .


pg-index-health , , , .



SSD , HA- -, - n- . – ; , CPU. , , , , , .


, , «» . , . . - – «» . , – Postgres . , duplicated_indexes.



. , , , . A, A+B, A+B+C .. , . intersected_indexes.



Postgres . , … …


: - job’, , «» . CPU IO , , . pg_stat_activity , :


delete from <table> where id in (…)

id , , , . , , , , .


explain analyze , , , sequential scan - . foreign_keys_without_index.


– null value


Postgres null btree-, , , . null’ ( indexes_with_null_values), nullable- where <A> is not null. 1877 16 . 16% ( 4.3 ) null . . :)



MVCC Postgres’ , bloat, . , , , , -!!!, … …


. +100 . , . , 15 , , . VACUUM FULL , pg_repack. , pg_repack , . tables_without_primary_key.


0.1.5 bloat’ .



tables_with_missing_indexes unused_indexes – . , .


, , . , - - , . , .


, , .



, . , , .


. , , . .


, bloat, . ClickHouse .


我真的希望pg-index-health会有用和有需求。您还可以通过报告发现的问题并提供新的诊断来为库的开发做出贡献。


All Articles