This is a Postgres extension that can determine if a query should have an index. For example, for this table:<p><pre><code> create table book(
id int primary key,
title text not null
);
</code></pre>
You can run `index_advisor()` to see if there should be an index on a select statement:<p><pre><code> select *
from index_advisor('select book.id from book where title = $1');
</code></pre>
And it will return (summarized):<p><pre><code> {"CREATE INDEX ON public.book USING btree (title)"}
</code></pre>
It works particularly well with pg_stat_statements[0] which tracks execution statistics of all SQL statements executed on your Postgres database.<p>It leans heavily on HypoPG[1], an excellent extension to determine if PostgreSQL will use a given index without spending resources to create them.<p>[0] pg_stat_statements: <a href="https://www.postgresql.org/docs/current/pgstatstatements.html" rel="nofollow">https://www.postgresql.org/docs/current/pgstatstatements.htm...</a><p>[1] <a href="https://github.com/HypoPG/hypopg">https://github.com/HypoPG/hypopg</a>
My partner usually writes substack posts which I then mirror to our website’s blog section.<p>To automate this, I made a simple tool to scrape the post and clean it so that I can drop it to our blog easily. This might be useful to others as well.<p>Oh and ofcourse you can instruct GPT to make any final edits :D