DEV Community

Mohammad Tejabwala
Mohammad Tejabwala

Posted on

SqlGo🌱 - Save CO2 by optimizing queries and removing redundant storage

DEV Weekend Challenge: Earth Day

This is a submission for Weekend Challenge: Earth Day Edition

What I Built

The challenge was to built something that could celebrate our planet. And what better way to celebrate then try to save it!

Introducing SqlGo, an SQL auditor which connects to your SnowFlake account, finds the historic executions of your query and with the help of Gemini, provides useful suggestions to optimize your query, in turn reducing the computation power needed to run them, which in turn would reduce the CO2 emissions and water maintenance needed for these datacentres to run

It also finds "zombie" — unused or stale tables within your schema that have not been accessed over time, and haven't been used, saving the redundant storage space.

Key features:

Feature Description
Secure Authentication Connects to Snowflake using credentials from a JSON file, stored only in the user's session for enhanced security.
Sustainability Dashboard A central, interactive dashboard displaying key metrics like annual CO2 saved, zombie tables found
High-Compute Query Auditing Automatically identifies and lists the most resource-intensive queries from the past week for on-demand analysis.
Zombie Table Detection Scans the database for tables that haven't been altered in over 30 days, helping to eliminate storage waste.
AI-Powered Optimization Integrates with Google Gemini to provide expert suggestions for rewriting inefficient queries to be more "Green".
Gamified Savings Features a rewarding animation and updates dashboard metrics when a user "Accepts" an optimization, encouraging eco-friendly practices.
Modern UI/UX A fully responsive, dark-themed interface with animated loaders, sortable tables, and a clean design for an intuitive user experience.

Demo

Code

earthday-hackathon

🚀 SqlGo – Key Features

SqlGo is designed to optimize database performance while promoting sustainability through intelligent insights and a modern user experience.

🔑 Features

  • Secure Authentication: Connects to Snowflake using credentials from a JSON file, stored only within the user's session to ensure enhanced security.
  • 📊 Sustainability Dashboard: A centralized, interactive dashboard showcasing key metrics such as annual COâ‚‚ savings, zombie tables identified, and compute efficiency.
  • âš¡ High-Compute Query Auditing: Automatically detects and lists the most resource-intensive queries from the past week, enabling targeted performance improvements.
  • 🧟 Zombie Table Detection: Identifies tables that have not been modified in over 30 days, helping reduce unnecessary storage usage.
  • 🤖 AI-Powered Optimization: Integrates with Google Gemini to suggest optimized, more efficient ("greener") versions of SQL queries.
  • 🎮 Gamified Savings: Encourages eco-friendly actions with interactive feedback—users receive visual rewards and updated metrics when they accept optimization…

How I Built It

Tech stack used:

  • Framework: Django (Python)
  • Database Integration: Snowflake Connector for Python
  • AI Engine: Google Gemini API (gemini-2.5-flash)

Design decisions:

  • Ease of Use: It was decided to include the table statistics as well into the schema, so that the end user may get an overview of the data and the storage space used. Based on that and the usage, indexes may be created to further optimize key tables.
  • Query Traceability & Analysis: Sql ids were included in the report for the queries that are taking a significant time so that the end user may leverage other tools based on the underlying database to analyse the SQL based on the id.
  • Efficient Token Utilization: Rather than collecting all the SQLs taking significant time and passing it to the Gemini layer, it was better to leave it to the end user to select which SQL to chose, in turn reducing the tokens wasted in analysing all the queries.
  • Privacy-First Stateless Architecture: Taking the input via a JSON object for the database credentials, and only storing them in the session, so that confidential user data may not be misused.

Prize Categories

  • Best use of Google Gemini: Used the Gemini API as the main engine of the system to provide analysis based on the data gathered from Snowflake. Also, this application was developed by using Gemini Code Assist and chat. (Chat works better in remembering the overall context I feel)
  • Best use of Snowflake: Used a pre-existing high-data schema in Snowflake and executed some of the compute intense queries resembling real-life examples, not just poor code! Futhermore, the Snowflake agent Cortex code helped a lot in understanding the schema, and debugging some of the prompt queries used in this application. It even helped in establishing the connection from python to snowflake :)

Future Improvements

Instead of a JSON based input, we could provide an option to directly connect with a Snowflake account to get continuous monitoring and audit

Fun Fact: The entire frontend of the application was done using Gemini Code Assist

Top comments (0)