I've been messing around with getting AI to reliably optimize complex SQL queries without constantly making errors. A prompt like: “You are a skilled SQL expert tasked with optimizing this: SELECT *...” doesn't get you far.<p>That's why I've chosen to divide the optimization process (step-by-step approach):<p>- AI suggests concrete optimization improvements
- The user selects the desired optimization improvement
- AI rewrites the SQL query according to the optimization improvement<p>This approach has several advantages:<p>- The user has full control over which optimization improvements are implemented
- AI can handle relatively complex SQL queries without making errors<p>Screencast: <a href="https://files.sqlai.ai/optimize-sql-query.mp4" rel="nofollow">https://files.sqlai.ai/optimize-sql-query.mp4</a><p>Try it out: <a href="https://www.sqlai.ai/app/optimize-sql" rel="nofollow">https://www.sqlai.ai/app/optimize-sql</a>