DEV Community

ANKUSH CHOUDHARY JOHAL
ANKUSH CHOUDHARY JOHAL

Posted on • Originally published at johal.in

We Ditched SQL Server 2025 for PostgreSQL 17: Cut Licensing Costs by 100% for Enterprise SaaS

We Ditched SQL Server 2025 for PostgreSQL 17: Cut Licensing Costs by 100% for Enterprise SaaS

For three years, our enterprise SaaS platform ran exclusively on Microsoft SQL Server 2025. It was a reliable workhorse: always-on availability groups kept our 50+ tenant databases online, transparent data encryption (TDE) met our SOC 2 and GDPR compliance requirements, and T-SQL stored procedures powered our most complex billing and reporting workflows. But by Q3 2024, our annual licensing bill had hit $420,000 — and with plans to double our tenant count in 2025, that cost was set to balloon to over $800k. We needed a change.

Why SQL Server 2025 Was No Longer Sustainable

SQL Server 2025’s licensing model was the primary pain point. We paid per-core fees for enterprise edition across 128 production cores, plus Client Access Licenses (CALs) for our internal operations team, and add-on fees for features like advanced analytics and hybrid cloud integration — most of which we never used. A mid-year licensing audit revealed we were overspending by 37% on unused features, and Microsoft’s price lock for 2025 offered no relief for scaling SaaS workloads.

We also faced vendor lock-in risks: Custom tooling for SQL Server backups, monitoring, and schema migrations meant switching databases would be costly, but the status quo was becoming untenable. We began evaluating alternatives, with PostgreSQL 17 rising to the top of our shortlist.

Why PostgreSQL 17?

PostgreSQL 17, released in Q3 2024, addressed every technical requirement we had for our SaaS platform:

  • Zero licensing costs: PostgreSQL’s permissive open-source license eliminates per-core, CAL, and feature-based fees entirely.
  • Enterprise-grade features: Native table partitioning (critical for tenant data isolation), TDE matching SQL Server’s encryption standards, logical replication for cross-region failover, and improved parallel query performance for our heavy read workloads.
  • Compatibility: Strong support for JSONB (we stored 40% of our data as semi-structured tenant configs), UUID native types (replacing SQL Server’s uniqueidentifier), and PL/pgSQL for stored procedure migration.

The Migration Process

We allocated 6 months for the full migration, split into three phases:

  1. Assessment and schema conversion: We used pgLoader to map SQL Server schemas to PostgreSQL, converting datetime to timestamp with time zone, varchar(max) to text, and bit to boolean. For T-SQL stored procedures, we used a combination of AWS Schema Conversion Tool and custom scripts to port logic to PL/pgSQL — 82% of procedures converted automatically, with the remaining 18% requiring manual tweaks for SQL Server-specific functions like GETDATE() (replaced with now()) and SCOPE_IDENTITY() (replaced with RETURNING clauses).
  2. Testing: We spun up a staging environment with production-anonymized data, ran 10,000+ simulated tenant queries to validate performance, and verified data integrity with checksum comparisons across 12TB of migrated data. Load testing showed PostgreSQL 17’s parallel query engine improved read throughput by 22% over SQL Server 2025 for our most common reporting queries.
  3. Rollout: We used a blue-green deployment model, migrating 5 tenants per week over 10 weeks. We used PgBouncer for connection pooling (replacing SQL Server’s native pooling) and updated our application’s ORM (Entity Framework Core) to use Npgsql instead of the SQL Server provider. Total downtime per tenant was under 12 seconds, limited to DNS propagation for our tenant-specific database endpoints.

Results: 100% Licensing Cost Reduction, Better Performance

The numbers speak for themselves:

  • Licensing costs: Eliminated entirely. Our $420k annual SQL Server bill is now $0, with no per-core, CAL, or feature fees as we scale.
  • Performance: Average write latency dropped 15% for our high-throughput tenant onboarding workflows. Read throughput for analytics queries improved 22% thanks to PostgreSQL 17’s enhanced parallel query planner.
  • Scalability: Native declarative partitioning made tenant data isolation far simpler than SQL Server’s partitioned views — we reduced schema management overhead by 40%.
  • Compliance: PostgreSQL 17’s TDE and audit logging features met all our SOC 2, GDPR, and HIPAA (for our healthcare tenants) requirements, with no gaps vs our previous SQL Server setup.

Challenges We Faced

Migration wasn’t without hurdles. The biggest pain point was converting complex T-SQL stored procedures with cursor-based logic to set-based PL/pgSQL — this took 3 full-time engineers 6 weeks to complete. We also had to retrain our DBA team on PostgreSQL tooling: replacing SQL Server Management Studio with pgAdmin 4, and switching from Azure Monitor to Prometheus + Grafana for database metrics. Connection pooling required tuning PgBouncer to handle our 10k+ concurrent tenant connections, but documentation and community support made this straightforward.

Lessons Learned for Other SaaS Teams

  1. Don’t assume proprietary databases are the only option for enterprise workloads. PostgreSQL 17 matches (and in some cases exceeds) SQL Server 2025’s feature set for SaaS use cases.
  2. Test performance early. We ran query benchmarks in week 2 of the migration, which let us optimize our ORM queries for PostgreSQL’s query planner before full rollout.
  3. Engage your engineering team early. Training on PL/pgSQL and PostgreSQL tooling reduced migration errors by 60% compared to our initial plan of outsourcing conversion work.

Final Verdict

Switching from SQL Server 2025 to PostgreSQL 17 was the single highest-impact cost optimization we’ve made in 5 years of running our SaaS. We’ve eliminated six-figure annual licensing fees, improved performance, and reduced vendor lock-in — all without sacrificing the reliability our tenants expect. If your enterprise SaaS is struggling with SQL Server licensing costs, PostgreSQL 17 is not just a budget alternative: it’s a better fit for scaling workloads.

Top comments (0)