Skip to content

Add caching of AutoQueries to improve performance #6

@bartread

Description

@bartread

Generating auto-queries can be expensive since reflection is used to walk over the types and generate SQL. The SQL itself can become quite large so there's a lot of appending to StringBuilders happening, which will obviously cause allocations and copying.

It would be better to cache auto-queries based on criteria such as:

  • The types involved
  • Parameter names
  • WHERE clause content and split on columns for custom WHERE clauses

You don't need to cache anything for calls to CustomQuery because Dapper will cache the queries itself. With AutoQueries this is just a way of avoiding large amounts of SQL generation for frequently repeated queries, which should noticeably improve performance under load.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions