Project ideas from Hacker News discussions.

Training a 4B model to produce 81% faster query plans than Postgres

📝 Discussion Summary (Click to expand)

Generating summary…


🚀 Project Ideas

HintGuard: LLM-Guided Query Hint Generator with Automated Verification

Summary

  • Generates pg_hint_plan hints from a SQL workload using an LLM, then validates each hint with EXPLAIN and plan‑equivalence checks to ensure the plan matches the query’s intent.
  • Core value: Provides safe, verifiable query optimizations that can be version‑controlled and integrated into CI/CD pipelines.

Details

Key Value
Target Audience Postgres developers and DBAs who want reliable hint‑based optimization without manual trial‑and‑error
Core Feature LLM proposes hints → automated verification via EXPLAIN, plan diff, and optional semantic checker → stores only validated hints
Tech Stack Python, psycopg2, transformers/llama.cpp (or HuggingFace Inference API), pg_hint_plan extension, GitHub Actions for CI
Difficulty Medium
Monetization Revenue-ready: SaaS subscription per database instance or usage‑based pricing

Notes

  • Directly answers fsmv’s concern: “But how will you know that the query plan actually does what your query asked for?” by providing automated verification.
  • Leverages polyphilz’s debug log idea to confirm Postgres actually used the hint.
  • Enables teams to treat hints as code: commit hints to git, run verification in CI, and roll back if validation fails.

PlanPilot: Incremental LLM Fine‑Tuning Service for Ongoing Query Optimization

Summary

  • Continuously fine‑tunes a compact LLM (e.g., via LoRA) on recent query statistics and workload, producing updated hint sets on a regular schedule akin to a backup.
  • Core value: Keeps query plans up‑to‑date with shifting data distributions while avoiding costly full retraining cycles.

Details

Key Value
Target Audience Teams with evolving data patterns (SaaS, analytics, IoT) who experience stale hints and performance regressions
Core Feature Incremental fine‑tuning of a distilled model using new query plans + stats, outputs versioned hint repositories
Tech Stack HuggingFace Transformers + PEFT (LoRA), PostgreSQL logical replication for stats collection, Kubernetes CronJob, pg_hint_plan for hint storage
Difficulty High
Monetization Revenue-ready: tiered pricing based on monthly query volume or number of hint updates

Notes

  • Addresses cannonpalms’ 95‑hour training pain: “can you afford to spend hours every now and then to update your 4B model?” by framing updates as lightweight, scheduled fine‑tuning.
  • Mirrors dvt’s backup analogy: “I think this would be likely comparable to a scheduled backup…”
  • Provides practical utility: reduces the risk of performance degradation due to outdated statistics without requiring massive compute each time.

SpecuPlan: Speculative Parallel Query Planner with LLM Fallback

Summary

  • Runs the native Postgres planner and an LLM‑based hint generator in parallel for each incoming query, selects the faster‑executing plan, and cancels the slower one, guaranteeing correctness via pg_hint_plan.
  • Core value: Captures LLM‑driven speedups when they exist while preserving a safe fallback to the traditional optimizer.

Details

Key Value
Target Audience Performance‑sensitive applications that want LLM optimization benefits without risk of regressions
Core Feature Speculative execution: submit query to both planners, use EXPLAIN to estimate cost, run both concurrently, cancel slower; LLM planner emits hints via pg_hint_plan
Tech Stack Go/Rust proxy using libpq, LLM inference via ONNX Runtime/TensorRT, pg_hint_plan extension
Difficulty Medium
Monetization Hobby

Notes

  • Embodies yipinwong’s hybrid idea: “What if we use a hybrid model of using both query optimizer and LLM? … Whichever produces better result, the database can use?”
  • Supports mattashii and HighlandSpring’s suggestion to run plans in parallel and cancel the slower one.
  • Offers a low‑risk path to adopt LLM suggestions, addressing concerns about hallucinations and non‑determinism raised by multiple commenters.

Read Later