Usage-based ranking for SQL completion (local, no AI service) #42479
Unanswered
tessarotto21
asked this question in
DBeaver Development
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
SQL completion proposals are ordered by match score and then alphabetically. On large databases the table you
use every day is somewhere in a list of thousands, and when the tables live in another schema you have to type
the schema name first every time. The editor does not learn anything from how you work.
Proposal
Rank completion proposals by what the user actually uses on each connection, IntelliSense style, but fully local
and lightweight: no LLM, no network, no extra database queries.
What it learns from
What it uses to rank
FROM orders JOIN, the tables joined withordersbefore come first)Usage only breaks ties: it never moves a worse text match above a better one, and never-used objects keep the
current order.
What changes in the popup
FROM/JOIN: the schema used most comes first (unless it is the default one), then the 5 recentlyused tables already qualified (e.g.
sales.orders o), one Enter away.t.).Storage and cost
.metadata, pruned to its most used entries. Itstores object names and keywords only, never literals or query results.
Benchmark (synthetic)
Offline benchmark on a synthetic ERP-like schema (480 tables, 8,350 columns) and simulated users writing queries for
30 days. Each query is evaluated before the model learns it. Keystrokes = letters typed until the wanted item is
first, plus Enter.
ONcolumn MRR: 0.154 → 0.803 (focused user).better than today in every scenario.
the net result is positive in every scenario.
Smoke-tested in the app on Oracle, PostgreSQL, SQL Server and SQLite (synthetic databases).
Questions
SQLQueryCompletionAnalyzerand theproposal comparator, so it only applies to the new engine (the default mode).
(b) completion integration, (c) learning from the editor. Would that be easier to review?
I have a working branch and can open the PRs if the approach makes sense.
This proposal and the code were prepared with AI assistance (Claude Code) and reviewed by me.
All reactions