LQO, the studio’s eighteenth project, is a learned query optimizer for PostgreSQL that steers the planner instead of replacing it. PostgreSQL picks each plan from row counts it guesses, and when two columns are related the guess can be off by thousands. LQO reads a server log or a file of queries, then runs each kind of query under the default plan and under 13 of PostgreSQL’s own planner settings, on a replica or a copy. It reports the settings that make a query clearly faster, with the SET LOCAL lines to use. Version 0.1.0 came out on 19 October as one Go binary with no dependencies, its own PostgreSQL client included, with binaries for Linux, macOS and Windows. It’s open source under Apache 2.0.
The rule is strict on purpose. A setting is suggested only when it’s never more than 10% slower on any text tried, clearly faster on at least one, and at least 20% faster overall. Every trial is an EXPLAIN ANALYZE in a read-only transaction that is rolled back, and LQO refuses a primary server unless told otherwise.
The test write-up sends writes past LQO’s own checks and has the server refuse them, kills the state file’s writer 40 times, and runs a demo shop built to fool the planner. There, a join the planner expected to touch about six customers went from 2,414 ms to 1,038 ms with nested loops switched off, and a query the same kind of fix would have slowed more than 300 times was left alone.
Version 0.1 is an advisor and changes nothing by itself. A proxy that learns from live traffic, first in shadow mode, is the next step.