Presenters

Source

🚀 Bridging the Gap: How AI is Supercharging SQL Performance at Dua 💡

Dealing with slow SQL queries can feel like wading through molasses. It’s frustrating, impacts API performance, and can derail even the most skilled developers. At Dua, they faced this problem head-on, and the solution they built – SQL Lens – is a brilliant example of how AI and schema intelligence can work together to unlock significant performance gains. Let’s dive into how they tackled this challenge and what we can learn from their innovative approach.

The Problem: A Complex Environment, A Common Pain Point 🌐

Dua operates a sprawling environment: 100+ microservices, 15+ database instances, and a staggering 50+ databases. Within this complexity, a recurring issue emerged: slow SQL queries impacting their Go applications. Here’s a breakdown of why this was such a persistent problem:

  • ORM Obscurity: Using ORMs (Object-Relational Mappers) simplifies development, but they can also hide the actual SQL being executed. This makes debugging slow queries incredibly difficult.
  • Query Complexity: The queries themselves often involved intricate joins, aggregations, and potentially over-normalized tables – a recipe for difficult-to-understand and maintain code.
  • Manual Debugging Nightmare: Traditional debugging required developers to manually decipher table structures, indexes, and relationships. This was time-consuming, error-prone, and frankly, a major drain on productivity.

🛠️ The Solution: Introducing SQL Lens – Your AI-Powered Schema Intelligence Tool 🤖

Recognizing the need for a better solution, Dua’s team built SQL Lens, an internal tool that leverages the power of AI to optimize SQL performance and provide unprecedented schema intelligence. Here’s how it works:

  • Centralized Schema Capture: SQL Lens automatically captures and centralizes database schema information from all instances and databases. This data is then exposed via an MCP (Management Console Protocol) server.
  • IDE Integration: The MCP server seamlessly integrates into developer IDEs, providing real-time schema intelligence right where developers are working.
  • AI-Powered Analysis & Optimization: This is where the magic happens. SQL Lens uses AI, including powerful LLMs like Cursor, Claude, Gemini, and Code Assist, to analyze queries, pinpoint inefficiencies, and generate optimization suggestions.
  • Iterative Improvement: SQL Lens fosters an iterative process: analyze, optimize, validate, repeat. This continuous feedback loop ensures ongoing performance improvements.

💾 Key Features & Benefits: A Game Changer for Developers ✨

SQL Lens isn’t just a tool; it’s a productivity multiplier. Here’s a look at the key benefits:

  • Faster Debugging: Say goodbye to endless hours spent debugging slow queries. SQL Lens drastically reduces the time it takes to identify and resolve performance bottlenecks.
  • Proactive Code Reviews: Identify potential performance issues before they hit production, leading to cleaner, more efficient code.
  • Accelerated API Development: Quickly build new APIs leveraging existing schema information – a huge win for development velocity.
  • Simplified Upgrades: Analyze upgrade paths and proactively identify potential problems, minimizing disruption.
  • Knowledge Sharing: Onboarding new developers becomes significantly easier with a centralized schema repository.
  • Automated Reporting: Generate quick, insightful reports based on database data with ease.

📡 Technical Deep Dive: How SQL Lens is Built

Let’s take a peek under the hood:

  • Architecture: Lambda functions periodically dump schema information to an object store. Another lambda function processes this data and stores it in a document store. The MCP server is built on top of this document store. This design allows for scalability and efficient data management.
  • Security First: Production and development environments are strictly segregated for enhanced security, with production environments providing only metadata access.
  • AI Integration: The tool intelligently leverages LLMs to not only analyze queries but also generate suggestions and automatically update code.
  • Deployment Success: Currently utilized by all developers at Dua, SQL Lens has been deployed for roughly 6 months and is proving its value.

🎯 Demo Highlights: From 17 Seconds to 2 Seconds! 🤯

During a demo, SQL Lens demonstrated its power by optimizing a query, reducing its execution time from a sluggish 17 seconds to a lightning-fast 2 seconds! The tool didn’t just identify the problem; it automatically suggested and generated the scripts needed to create the necessary index. This is a concrete example of how SQL Lens can dramatically improve performance with minimal manual intervention.


SQL Lens represents a powerful combination of AI, schema intelligence, and developer tooling. It’s a testament to what can be achieved when you tackle complex problems with innovative solutions. If you’re struggling with SQL performance bottlenecks, consider how similar principles could be applied in your own environment. The future of database management is intelligent, and Dua is leading the way!

Appendix