PGSQLTune : Postgresql SQL Tunning Advisor
PGSQLTune , PostgreSQL veritabanlarınızda çalışan sorgular için iyileştirme önerileri sunan bir eklentidir. Şuan için basit seviye öneriler sunmaktadır. Geliştirme süreci devam eden ürünümüz ileride çok daha fazla öneriler sunabilir hale gelecektir.
PGSQLTune eklentisini indirmek için buraya tıklayın.
Kurulum :
Öncelikle indirilen dosyayı bir dizine açın.
$ unzip pgsqltune.zip
Daha sonra Linux terminal ekranından aşağıdaki şekilde binary paket kurulumu yapılmalıdır. pg_config aracına ihityaç olduğundan pg_config olan dizin PATH değişkeninde yer almalıdır. Örnel olarak 17 sürümünün binary dizini PATH değişkenine eklenmiştir. Kurulu olan Postgresql sürümüne göre dizini değiştirmeniz gerekmektedir.
$ cd /path/to/pgsqltune
$ export PATH=$PATH:/usr/pgsql-17/bin/
$ make
$ make USE_PGXS=1 install
Sonrasında psql ile bağlanıp ekletiyi oluşturmanız gerekmektedir.
postgres=# CREATE EXTENSION pgsqltune;
Kullanımı :
SELECT pg_sqltune($$<sql_text>$$);
Örnek :
postgres=# SELECT pg_sqltune($$SELECT * FROM employees WHERE age > 30 AND department = 'Dept 2'$$);
pg_sqltune
-------------------------------------------------------------------------------------------------------------------------------------------------------------
FUNCTIONAL EXPRESSION: Filter "((employees.age > '30'::numeric) AND ((employees.department)::text = 'Dept 2'::text))" contains function calls. +
Consider creating a functional index if this filter is used frequently. +
Example: CREATE INDEX idx_employees_expr ON employees USING btree((((employees.age > '30'::numeric) AND ((employees.department)::text = 'Dept 2'::text))));+
+
FILTER CONDITION: Table employees has filter on column age (((employees.age > '30'::numeric) AND ((employees.department)::text = 'Dept 2'::text))) +
Recommendation: CREATE INDEX idx_employees_age ON employees(age); +
+
FILTER CONDITION: Table employees has filter on column department (((employees.age > '30'::numeric) AND ((employees.department)::text = 'Dept 2'::text))) +
Recommendation: CREATE INDEX idx_employees_department ON employees(department); +
+
MULTI-COLUMN FILTER: Consider composite index for columns age,department +
Recommendation: CREATE INDEX idx_employees_comp ON employees(age,department); +
Column order suggestion: Place high-selectivity columns first +
+
+
GENERAL RECOMMENDATIONS: +
- Run VACUUM ANALYZE on tables to update statistics +
- Consider increasing work_mem for complex sorts/hashes +
- Review shared_buffers and maintenance_work_mem settings +
- For large tables, consider partitioning strategies +
- Use prepared statements for frequently run queries +
- Check for unused indexes that could be dropped +
+
QUERY ID: 5953ded824e82e73c4fe69bd825d1a21 +
HASH: 1092610392 +
+
+
CURRENT SETTINGS: +
work_mem = 4MB\nshared_buffers = 128MB\nmaintenance_work_mem = 64MB\nrandom_page_cost = 4\neffective_cache_size = 4GB\n
(1 row)
postgres=#
![]()
