DapperLib / DapperLib/DapperAOT

Using non-const string query performance

Open
#134 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
472
Forks
43
Avg merge
1d 4h
Merged PRs (30d)
18

Description

There seems to be a big performance hit in DapperAOT when using locally built string as a query.

Example:
Bad performance

string sql = "SELECT * FROM table1"
connection.Query(sql);

Good

const string sql = "SELECT * FROM table1"
connection.Query(sql);

This does not happen with Dapper.
The performance hit can be quite big for lengthy queries that are heavily repeated - like doing a transaction with 10k update queries. We noticed query being 5 times slower.
While using const string can be a solution in some case, it becomes an issue when the query need to be assembled at runtime based on different parameters (like for filters)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported performance difference between const and locally built strings in DapperAOT, including repeated updates and runtime-assembled filters. Compare the same cases with Dapper and measure whether non-const queries still incur the reported slowdown; done means runtime-built queries no longer show that performance hit.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.