Improving queries with AI
NovaSql can have an AI rework a query: more readable, faster, more robust. Which AI does it, Claude in the cloud or a local model, is set up in Setting up AI.
How it works
- Open the query in the editor.
- Click AI Improve in the toolbar, press Ctrl+I or choose AI: Improve in the context menu.
- A comparison opens: the original on the left, the improved version on the right, changes highlighted.
- Apply replaces the editor's content with the improved version. Discard closes the dialog without changing anything.
The entire content of the editor is always improved.
What the AI typically changes
- rewrites non-sargable conditions so indexes can be used
- replaces
SELECT *with the columns actually needed - turns nested subqueries into
JOINs or CTEs - makes formatting and aliases consistent
Important
- Review before you apply. The AI does not know your data and can be wrong. The comparison is there for exactly that.
- After applying, take a look at the execution plan and statistics: did the logical reads go down?
- With Anthropic Claude the editor's content goes to Anthropic. For sensitive queries choose a local provider, see Privacy and your data.
- Local models are slower and less thorough. For complex queries Claude usually gives clearly better results.