A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://devblogs.microsoft.com/python/mssql-python-vs-pyodbc-benchmarking-sql-server-performance/ below:

mssql-python vs pyodbc: Performance Benchmarks Comparison

Reviewed by Imran Masud and Sumit Sarabhai

When it comes to working with Microsoft SQL Server in Python, pyodbc has long been the de facto driver. It’s mature, trusted and has been serving the community well for years.

But as applications scale and Python becomes more central to modern data workflows — from microservices to data engineering and platforms like Microsoft Fabric — there’s a growing need to modernize and improve the developer experience. 

So, can we take this further?

Meet mssql-python – a modern SQL Server driver for Python that rethinks the architecture from the ground up while preserving a familiar experience for developers. It is purpose-built for:

To evaluate how it stacks up against pyodbc, we ran a comprehensive suite of performance benchmarks using the excellent Richbench tool. The results? Let’s just say they speak volumes.

What makes mssql-python different? Powered by DDBC – Direct Database Connectivity

Most Python SQL Server drivers, including pyodbc, route calls through the Driver Manager, which has slightly different implementations across Windows, macOS, and Linux. This results in inconsistent behavior and capabilities across platforms. Additionally, the Driver Manager must be installed separately, creating friction for both new developers and when deploying applications to servers. 

With mssql-python, we made a bold decision. At the heart of the driver is DDBC (Direct Database Connectivity) — a lightweight, high-performance C++ layer that replaces the platform’s Driver Manager.

Key Advantages:

Why This Architecture Matters?

By owning the layer that the ODBC driver depends on, DDBC delivers:

This architecture gives mssql-python its core advantages – speed, control and simplicity.

Built with PyBind11 + Modern C++ for Performance and Safety

To expose the DDBC engine to Python, mssql-python uses PyBind11 – a modern C++ binding library, instead of ctypes. Why is that important?

With ctypes, every call between Python and the ODBC driver involved costly type conversions, manual pointer management, and is slow and unsafe.

PyBind11 solves all of this. It provides:

Benchmark Setup

Benchmark Script

If you want to reproduce or extend our tests, checkout the complete script on

GitHub

.

Benchmark Summary

mssql-python outperforms pyodbc across most operations:

Category

mssql-python vs. pyodbc Core SQL (SELECT, INSERT, UPDATE, DELETE) 2× to 4× faster Join, Nested, and Complex Queries 3.6× to 4× faster Fetch Operations (One & Many) 3.6 to ~3.7× faster Stored Procedures, Transactions ~2.1× to ~2.6× faster Batch Inserts 🔥~8.6x faster 1000 Connections 🔥16.5x faster

Across the board, the mssql-python driver demonstrated significantly faster execution times for common SQL operations, especially on:

These results indicate highly efficient execution paths, minimal overhead, and strong connection reuse capabilities.

Disclaimer on Performance Benchmarks

The performance tests comparing mssql-python and pyodbc were conducted using a controlled set of queries designed to evaluate core driver capabilities. Real-world results may vary based on query patterns, data volumes, and system configurations.

We welcome feedback and real-world usage insights from the community. If you encounter performance issues or have suggestions, please raise issues on Github, we’re actively listening and committed to improving the experience.

Visual Snapshot

We captured this benchmark data in a clean tabular format using richbench tool. Here’s a quick glance at the relative performance:

Analysis & Insights What’s Next?

We’re actively improving the driver and here’s what’s in the pipeline:

Performance tuning is a key priority, and we’re committed to delivering consistent improvements in upcoming releases.

Join the Journey

If you’re building high-performance apps with SQL Server in Python, mssql-python is a fast, modern and compelling alternative to pyodbc. It is:

Join the Early Customer Program

If you’re interested in becoming an early dogfooder and showcase your journey at

Microsoft Ignite

– we’d love to hear from you!

Apply here to join the Early Customer Program.

🚀Get early access, influence the roadmap, and work directly with the team!

Try It and Share Your Feedback! 

We invite you to: 

  1. Check-out the mssql-python driver and integrate it into your projects. 
  2. Share your thoughts: Open issues, suggest features, and contribute to the project. 
  3. Join the conversation: GitHub Discussions | SQL Server Tech Community

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4