Skip to content

v0.5.0 - Enterprise-Ready Database Query Builder

Latest

Choose a tag to compare

@kolkov kolkov released this 13 Nov 22:45

Release Date: November 14, 2025

Relica v0.5.0 transforms the library from a lightweight query builder into an enterprise-ready database solution with comprehensive security, optimization, and monitoring capabilities - while maintaining zero production dependencies.


🎯 Major Features

🛡️ Enterprise Security

SQL Injection Prevention

  • Pattern-based validation with OWASP Top 10 coverage
  • 20+ dangerous patterns detected (stacked queries, UNION attacks, code execution)
  • Strict mode for maximum security
  • <2% performance overhead for protected queries
  • Zero false positives for legitimate queries

Audit Logging

  • Context-based tracking (user, client IP, request ID)
  • Three audit levels: writes-only, reads+writes, all operations
  • Parameter hashing for privacy compliance (SHA256)
  • Security event logging for blocked queries
  • GDPR, HIPAA, PCI-DSS, SOC2 compliance support
// SQL injection prevention
validator := security.NewValidator(security.WithStrict(true))
db, _ := relica.NewDB("postgres", dsn, relica.WithValidator(validator))

// Audit logging for compliance
auditor := security.NewAuditor(logger, security.AuditAll)
db, _ := relica.NewDB("postgres", dsn, relica.WithAuditLog(auditor))

🎯 Query Optimizer

4-Phase Optimization System

  • Phase 1: Missing index detection and query cost analysis
  • Phase 2: Advanced index analysis (covering indexes, index-only scans)
  • Phase 3: Database-specific optimization hints
  • Phase 4: Complete documentation and examples

Automatic Recommendations

  • Suggests missing indexes for slow queries
  • Identifies inefficient query patterns
  • Database-specific optimization advice (PostgreSQL, MySQL, SQLite)
  • Integrates with Query Analyzer for actionable insights
optimizer := optimizer.NewBasicOptimizer()
db, _ := relica.NewDB("postgres", dsn, relica.WithOptimizer(optimizer))
// Automatic optimization suggestions for queries >100ms

📊 Query Analyzer

EXPLAIN Plan Integration

  • PostgreSQL: Full EXPLAIN ANALYZE support
  • MySQL: EXPLAIN FORMAT=JSON with execution stats
  • SQLite: EXPLAIN QUERY PLAN analysis
  • Execution time tracking with configurable thresholds
  • Async analysis to avoid blocking queries

Performance Insights

  • Seq scan detection on large tables
  • JOIN operation analysis
  • Index usage verification
  • Memory and I/O statistics

📝 SQL Logging & Distributed Tracing

Structured Logging

  • Go 1.21+ slog integration
  • Automatic parameter sanitization (masks passwords, API keys, tokens)
  • Query execution time tracking
  • Configurable log levels

OpenTelemetry Tracing

  • Full distributed tracing support
  • Automatic span creation for all database operations
  • Context propagation across service boundaries
  • Compatible with Jaeger, Zipkin, DataDog, New Relic
// Structured logging with slog
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
db, _ := relica.NewDB("postgres", dsn, relica.WithLogger(logger))

// OpenTelemetry tracing
tracer := otel.Tracer("relica")
db, _ := relica.NewDB("postgres", dsn, relica.WithTracer(tracer))

⚡ Performance Monitoring

Connection Pool Management

  • Advanced health checks with automatic degradation detection
  • Pool statistics and metrics
  • Connection lifetime management
  • Health endpoint ready for Kubernetes liveness probes

Statement Cache Enhancements

  • Cache warming for reduced cold-start latency (~185µs for 100 queries)
  • Query pinning for critical queries (always cached)
  • LRU eviction with configurable size
  • <60ns cache hit latency (sub-nanosecond)
// Cache warming for faster startup
db.WarmCache([]string{
    "SELECT * FROM users WHERE id = ?",
    "SELECT * FROM products WHERE sku = ?",
})

// Pin critical queries
db.PinQuery("SELECT * FROM config WHERE key = ?")

📚 Comprehensive Documentation (10,000+ Lines)

Migration Guides (1,400 lines)

User Guides (2,000 lines)

Security Guides (1,360 lines)

Performance Documentation (450 lines)

Feature Guides (5,000+ lines)


🔄 Changes

  • Removed "beta" suffix - v0.x already allows breaking changes per semantic versioning
  • Upgraded Codecov from v4 to v5 with token authentication
  • Added minimum 70% coverage requirement with automated enforcement
  • CI/CD enhancements - Added triggers for release/** and hotfix/** branches
  • README.md modernized - Removed version news section, follows 2025 best practices

🐛 Fixes

Code Quality

  • Resolved 8 golangci-lint warnings:
    • Removed unnecessary type conversion in Stats() method
    • Renamed unused context parameter in analyzeQuery()
    • Extracted validation logic to reduce nesting complexity (DRY principle)
    • Extracted logging logic to improve maintainability
    • Added justified nolint directives for inherently complex query paths

Formatting & Organization

  • Fixed code formatting across 14 files (gofmt compliance)
  • Added .gitignore patterns for private documentation and navigation files
  • Organized internal documentation into docs/dev/ (excluded from repository)

📊 Statistics

  • 326+ tests with 93.3% coverage
  • Zero production dependencies (only Go standard library)
  • 32 commits across 5 major feature tasks
  • 72 files changed, 19,809+ lines added
  • 10,000+ lines of professional documentation
  • 5 new internal packages: analyzer, logger, optimizer, security, tracer

🚀 Upgrade Guide

From v0.4.1-beta

This is a non-breaking release. All existing code continues to work unchanged.

New Optional Features (opt-in only):

import (
    "github.com/coregx/relica"
    "github.com/coregx/relica/internal/logger"
    "github.com/coregx/relica/internal/optimizer"
    "github.com/coregx/relica/internal/security"
)

// Add any combination of new features
db, err := relica.NewDB("postgres", dsn,
    relica.WithLogger(logger.New()),              // Structured logging
    relica.WithOptimizer(optimizer.NewBasic()),   // Query optimization
    relica.WithValidator(security.NewValidator()), // SQL injection prevention
    relica.WithAuditLog(auditor),                 // Audit logging
)

No changes required for existing code - all new features are optional.


🔗 Links


💬 Feedback

Found a bug? Have a feature request? Open an issue


Full Changelog: v0.4.1-beta...v0.5.0