Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Awesome, the Index Advisor sped my slowest query 4x! Is there a way to run that across all queries in pg_stat_statements at once or do I need to click on each one?


In Studio you'd need to click on a query to get the recommendations but the most important queries to optimize are on several metrics like "Most time consuming", "Most frequent", "Slowest execution" are sorted worst-to-best in tab views.

But if you do want to scan all of your queries at once for possible indexes you can do it in SQL with

```sql

create extension index_advisor cascade schema extensions;

select ia., pss.query

from pg_stat_statements pss, lateral( select from extensions.index_advisor(pss.query)) ia

order by (total_cost_after::numeric - total_cost_before::numeric)

limit 100;

```




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: