News for hackers. Stuff that matters.
Re:Show HN: PostgreSQL Index Advisor by elric on Sunday April 14, 2024 @02:01AM (#40029013)
I'm sure the database could, but it doesn't mean the database should. Indexes come at the cost of extra disk space, slower inserts, and slower updates. In some cases, some slower queries might be an acceptable tradeoff. In other cases, maybe not. It depends.
Re:Show HN: PostgreSQL Index Advisor by kiwicopple on Sunday April 14, 2024 @03:15AM (#40029293)
this is our posture for this extension on the supabase platform. we could automate the creation of the indexes using the Index Advisor, but we feel it would be better to expose the possible indexes to the user and let them choose
Re:Show HN: PostgreSQL Index Advisor by gneray on Sunday April 14, 2024 @09:24AM (#40030891)
this is the way ^^
Re:Show HN: PostgreSQL Index Advisor by dmurray on Sunday April 14, 2024 @01:16PM (#40032627)
You could tell it "you have a budget of X GB for disk space, choose the indexes that best optimize the queries given the budget cap."

Not perfect, because some queries may be more time-critical than others.

You could even annotate every query (INSERT and UPDATE as well as SELECT) with the dollar amount per execution you're willing to pay to make it 100ms faster, or accept to make it 100ms slower. Then let it know the marginal dollar cost of adding index storage, throw this all into a constraint solver and add the indexes which are compatible with your pricing.

Re:Show HN: PostgreSQL Index Advisor by d0100 on Sunday April 14, 2024 @01:22PM (#40032671)
Are the trade-offs measurable? If they are the database could just undo the index...

Not just indexing, but table partitions, materialized views, keeping things in-memory...

Re:Show HN: PostgreSQL Index Advisor by remus on Sunday April 14, 2024 @02:16PM (#40033134)
> Are the trade-offs measurable?

Yes, but you need the context about what is the correct tradeoff for your use case. If you've got a service that depends on fast writes then adding latency via extra indices for improved read speed may not be an acceptable trade off. It depends on your application though.