Re:Supabase – General Availability Week
by noob-4-life on Monday April 15, 2024 @11:29AM
(#40041877)
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?
[ Parent
| on HN ]
Re:Supabase – General Availability Week
by oliverrice on Monday April 15, 2024 @11:38AM
(#40042002)
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;
```