GenDB: Instance-Optimized Query Code Generation with LLMs

See how GenDB uses LLM agents to generate instance-optimized query code, outperforming traditional engines on TPC-H and more. Try it with your data!

sábado, 25 de julio de 2026 • 5 min read • Q2BSTUDIO Team

Optimización de consultas SQL con LLM y generación de código

The evolution of traditional query engines has been marked by increasing complexity and the constant need for extensions to support new techniques and user requirements. However, these systems are often difficult to extend due to their internal architecture, and building one from scratch involves significant engineering effort and cost. In this context, GenDB emerges as a generative query engine that shifts query processing from manually engineered systems to code generation driven by large language models (LLMs). This approach promises to revolutionize how companies manage their data, offering optimized and adaptive performance.

GenDB uses LLM agents to generate query execution code optimized for specific instances, taking into account the data, workloads, and available hardware resources. In its initial prototype, it focuses on offline code generation for repetitive and template-based queries, where the initial generation cost is amortized over multiple executions and correctness is ensured through extensive testing and manual review. For ad-hoc queries, GenDB can work in a hybrid architecture with a traditional DBMS: the DBMS handles one-off queries, while GenDB accelerates frequent SQL templates. This combination allows companies to get the best of both worlds: flexibility and performance.

From a technical perspective, GenDB represents a qualitative leap in query optimization. The engine analyzes the workload, profiles hardware resources and underlying data, produces query plans, generates code based on them, and finally uses an optimizer to iterate until a correct and efficient implementation is achieved. This automated process overcomes the limitations of traditional optimizers, which rely on fixed rules and approximate statistics. By leveraging the ability of LLMs to understand patterns and generate adaptive code, GenDB achieves significantly better performance than state-of-the-art query engines, as demonstrated on benchmarks like TPC-H and a new test suite designed to avoid data leakage from LLM training.

For companies looking for custom software solutions, GenDB opens up new possibilities. The ability to generate optimized code for each query instance allows processing to be tailored to the specific needs of each business, without the limitations of generic engines. This is especially relevant in environments where queries are repeated frequently, such as periodic reports, sales analysis, or ETL processes. Moreover, integration with cloud services like AWS and Azure further enhances scalability and cost reduction, by allowing optimized queries to run on elastic infrastructures.

At Q2BSTUDIO, as a software development and technology company, we understand that innovation in data processing is key to business competitiveness. Our experience in artificial intelligence, cybersecurity, and business intelligence enables us to accompany organizations in adopting tools like GenDB and creating customized solutions that maximize the value of their data. For example, implementing AI agents to optimize queries can be combined with BI and Power BI strategies to offer real-time dashboards with accurate and up-to-date information. Likewise, cybersecurity is a fundamental pillar: by generating specific code for each query, attack surfaces are reduced and more granular access controls can be applied, protecting sensitive data.

GenDB's approach also has deep implications for process automation. By replacing traditional query engines with dynamic code generation, companies can reduce dependence on data engineers for repetitive tasks, freeing up resources for strategic initiatives. LLM-based code generation also allows greater adaptability to changes in data or business requirements, as agents can automatically re-optimize queries without manual intervention. This fits perfectly with the automation services we offer at Q2BSTUDIO, where we help companies transform their processes through intelligent software.

One of the most attractive aspects of GenDB is its ability to work in hybrid environments, combining with existing DBMS systems. This means organizations do not need to replace their entire data infrastructure; they can integrate GenDB progressively, starting with the most critical or repetitive queries. The interactive demonstration of the engine allows users to visually explore how it analyzes workloads, profiles resources, generates plans, and iteratively optimizes code. Additionally, they can upload their own data and queries to experiment with different LLMs and query patterns, making it easy to evaluate the impact in their specific case.

From a performance standpoint, GenDB's results on standard benchmarks like TPC-H are impressive. The adaptive code generation outperforms traditional engines by speed factors, especially on complex queries with multiple joins and aggregations. The new benchmark designed to avoid data leakage from LLM training ensures that improvements are not due to the model memorizing previous solutions, but to its ability to reason and generate efficient code on the fly. This reinforces the technology's credibility and opens the door to its adoption in production environments where correctness and performance are critical.

For companies already using business intelligence with tools like Power BI, integration with GenDB can represent a qualitative leap in the speed of reports and dashboards. Queries that used to take minutes can now run in seconds, enabling real-time analysis and faster decision-making. Moreover, since the code is generated specifically for each query and hardware, cloud resource usage is optimized, reducing computing costs. At Q2BSTUDIO we offer consulting and development to implement these synergies, helping companies get the most out of their BI and cloud investments.

Cybersecurity also benefits from this approach. By generating adaptive query code, row- or column-level access controls can be included directly in the generated code, preventing data leaks and ensuring regulatory compliance. LLM agents can be trained to follow specific security policies, reducing the risk of human errors in permission configuration. At Q2BSTUDIO, our cybersecurity services include audits and pentesting to ensure these solutions are robust against threats.

In conclusion, GenDB represents a paradigm shift in query processing, moving away from static engines toward dynamic and intelligent code generation. Its ability to optimize repetitive queries and work in hybrid mode with traditional systems makes it a valuable tool for any organization handling large volumes of data. At Q2BSTUDIO, as a software development and technology company, we are prepared to help companies explore and implement these innovations, combining our expertise in artificial intelligence, cloud, cybersecurity, and business intelligence. If your company seeks to improve query performance and adapt data processing to your specific needs, the path toward code generated by LLM agents is a safe bet.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.