QRefine 🚀
The Ultimate SQL Query Analysis & Optimization Extension for VS Code
QRefine is an intelligent SQL analysis extension that helps developers write better, more performant, and safer SQL queries. It provides real-time analysis, inline suggestions, and automated fixes directly in your VS Code editor.

✨ Features
🔍 Real-time SQL Analysis
- Automatic Analysis: Analyzes SQL files on open, save, and change
- Inline Suggestions: GitLens-style inline annotations with severity indicators
- Problems Panel Integration: All issues appear in VS Code's Problems panel
- Status Bar Integration: Quick access via status bar shortcut
🛡️ Built-in SQL Rules (Phase 1 - MVP)
- SELECT * Detection: Warns against using
SELECT *
for better performance
- JOIN without ON: Prevents Cartesian products from missing JOIN conditions
- LIKE with Leading %: Identifies patterns that prevent index usage
- ORDER BY without LIMIT: Warns about potentially large result sets
- Dangerous Operations: Flags DELETE/UPDATE without WHERE clauses
- INSERT Best Practices: Suggests explicit column specifications
- SELECT Optimization: Recommends WHERE clauses for better performance
⚡ Quick Fix Framework
- One-click Fixes: Automated code actions for common issues
- Smart Replacements: Context-aware suggestions with proper syntax
- Batch Operations: Fix all issues in file or workspace
🎯 Developer Experience
- Zero Configuration: Works out of the box with sensible defaults
- Multi-Database Support: PostgreSQL, MySQL, SQL Server, SQLite
- Performance Optimized: <500ms analysis for files up to 10k lines
- Memory Efficient: <50MB additional VS Code memory usage
🚀 Quick Start
- Install QRefine from the VS Code Marketplace
- Open any
.sql
file - analysis starts automatically
- View suggestions as inline annotations and in the Problems panel
- Apply fixes using Quick Fix (Ctrl+.) or Code Actions
📋 Requirements
- VS Code: Version 1.103.0 or higher
- Node.js: For development and custom rules
- Database Connection (Optional): For live analysis features
⚙️ Extension Settings
QRefine contributes the following settings:
Database Configuration
qrefine.db.type
: Database type (postgres
, mysql
, sqlserver
, sqlite
)
qrefine.db.host
: Database host (default: localhost
)
qrefine.db.port
: Database port (default: 5432
)
qrefine.db.user
: Database username (default: dev
)
qrefine.db.password
: Database password
qrefine.db.database
: Database name (default: mydb
)
Analysis Settings
qrefine.analysis.enabled
: Enable/disable automatic analysis
qrefine.analysis.severity
: Default severity level for suggestions
qrefine.rules.custom
: Custom rule definitions
🎯 Roadmap
✅ Phase 1 - MVP (Current)
- [x] Automatic SQL Analysis
- [x] Inline Suggestions & Diagnostics
- [x] Quick Fix Framework
- [x] 8 Core SQL Rules
- [x] Status Bar Integration
🔄 Phase 2 - Enhanced Analysis
- [ ] Performance Anti-patterns (unused tables, redundant DISTINCT)
- [ ] Security Patterns (SQL injection detection, PII leaks)
- [ ] Configuration System (
.qrefinerc.json
)
- [ ] Multi-DB Dialect Awareness
🎨 Phase 3 - Developer Experience
- [ ] Interactive Rule Explorer Panel
- [ ] Enhanced Code Actions
- [ ] Query Performance Scoring
- [ ] Best Practice Templates
🧠 Phase 4 - Schema-Aware Analysis
- [ ] Mock Schema Support (offline)
- [ ] Live Database Integration (optional)
- [ ] Index Simulation & Query Plan Estimation
- [ ] Cross-Query Analysis
🤖 Phase 5 - AI-Powered Intelligence
- [ ] Query Rewriter with AI
- [ ] Plain English Explanations
- [ ] Smart Context-Aware Suggestions
- [ ] Learning from User Patterns
🛠️ Commands
QRefine provides the following commands:
QRefine: Run SQL Query Analysis
- Manually trigger analysis
QRefine: Connect to Database
- Connect to live database
QRefine: Analyze Query
- Analyze current query
📊 Supported SQL Rules
Rule |
Severity |
Description |
avoid-select-star |
Warning |
Avoid SELECT * for better performance |
join-without-condition |
Error |
JOIN without ON/USING clause |
like-leading-percent |
Warning |
LIKE with leading % prevents indexing |
order-by-without-limit |
Warning |
ORDER BY without LIMIT clause |
delete-without-where |
Error |
DELETE without WHERE clause |
update-without-where |
Error |
UPDATE without WHERE clause |
insert-without-columns |
Warning |
INSERT without explicit columns |
select-without-where |
Warning |
SELECT without WHERE clause |
🔧 Development
Prerequisites
- Node.js 18+
- TypeScript 5.9+
- VS Code Extension Development Tools
Setup
git clone https://github.com/your-org/qrefine.git
cd qrefine
npm install
npm run compile
Testing
npm run test
npm run lint
Building
npm run package
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
Adding New Rules
- Create a new rule file in
src/rules/
- Implement the
SQLRule
interface
- Add to the rules array in
src/rules/index.ts
- Write tests for your rule
- Analysis Speed: <500ms for files up to 10k lines
- Memory Usage: <50MB additional VS Code memory
- Extension Size: <10MB download, <25MB installed
- Rule Accuracy: >95% true positive rate
- False Positive Rate: <5% for critical rules
🐛 Known Issues
- Complex nested queries may have false positives
- Some database-specific syntax not yet supported
- Large files (>50k lines) may experience slower analysis
📝 Release Notes
0.0.1 (Current)
- Initial MVP release
- 8 core SQL analysis rules
- Inline suggestions and diagnostics
- Quick fix framework
- Status bar integration
Upcoming
- Enhanced rule set with 20+ patterns
- Configuration system
- Performance scoring
- Schema-aware analysis
📚 Resources
📄 License
MIT License - see LICENSE file for details.
🙏 Acknowledgments
- VS Code Extension API team
- SQL community for best practices
- Contributors and early adopters
Made with ❤️ for the SQL developer community
