How Dapper's String Parameter Handling Can Defeat SQL Server Index Performance
By
PretzelFisch
Slow-proofed and worth the wait. Worth its weight in flour.
Summary
This technical article explains a specific performance issue in SQL Server when using Dapper ORM with C# strings. The author discovered that when using anonymous objects to query varchar columns, Dapper sends nvarchar(4000) parameters by default, causing SQL Server to perform CONVERT_IMPLICIT operations on every row. This conversion defeats database indexes and leads to significant performance degradation, including high CPU usage. The article provides detailed analysis of the problem, benchmark results, and practical solutions including explicit parameter typing and configuration changes to prevent the issue.
Key quotes
· 5 pulledIf you're using Dapper with anonymous objects to query varchar columns, you're probably sending nvarchar(4000) parameters — causing CONVERT_IMPLICIT on every row and defeating your indexes.
The application was running hot — CPU averaging over 50% and spiking into the 90s. We pulled a diagnostic snapshot and started working through the performance issue.
The underlying issue is 100% real — we found it in a production system using AI-assisted code analysis.
The future of writing is collaborative, folks.
Here's the fix: Explicitly type your parameters or configure Dapper to use the correct string type for your database schema.
You might also wanna read
Why Average LLM Use Is Likely Destroying Value in Software Development
The author argues that, contrary to prevailing hype, the average use of Large Language Models (LLMs) is likely destroying value rather than
How AI Accelerated Prototyping: From Idea to Tangible in Record Time
The author reflects on how AI has transformed their prototyping workflow. Previously, the biggest bottleneck was the time needed to scaffold
GitLab 19.0 launches with Secrets Manager, agentic workflows, and self-hosted AI models
GitLab 19.0 has been released, positioning itself as an intelligent orchestration platform for DevSecOps. The release includes expanded secr
bit.ly·23h agoCentralizing Error Handling in Rust with Custom AppError Enums
This article discusses the importance of centralizing error handling in Rust applications using a custom AppError enum combined with map_err
Zig Devlog: Build System Rework Separates Maker and Configurer Processes
This devlog entry from the Zig programming language project announces a major rework of the build system, separating the maker process from
Study finds most developers refuse to code without AI, raising quality concerns
A February 2026 study by AI research lab METR reveals that most developers now refuse to work without AI coding tools. While these tools hel
