question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linq2db keeps adding N to varchar in queries even if column of view is varchar slowing down a lot the execution

See original GitHub issue

I’m having very slow queries cause linq2db keeps adding N in front of varchars in the generated query even if the column on witch the comparison is done is varchar and not nvarchar. Why is that? Removing the N the query is much faster.

The code used in the where clause below. I use a list of strings and contains to ensure that a column is present in those values.

where mtListOfStrings.Contains(myColumnName)

How can I avoid this behaviour?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MaceWinducommented, May 4, 2022

Yes. in C# we have string type only but database usually have several text types and we don’t know which one is used

0reactions
iColdoCatalincommented, May 4, 2022

@MaceWindu thanks again! very clear and fast to respond 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

LINQ Search nvarchar(MAX) column extremely slow using . ...
I have indexes in the database but cannot add one for CompanyName as it is Nvarchar(MAX). I have also looked at the execution...
Read more >
Query Performance Issues on VARCHAR Data Type Using ...
In this article, we'll discuss data type VARCHAR and query performance issues associated with utilizing the lower level VARCHAR data type.
Read more >
Avoiding Entity Framework Slowdown
Because Entity Framework assumes my column is a Unicode column, it slaps the N in front of my string constant ('Vogel') to turn...
Read more >
Indexed varchar column very slow (40M+ rows)
Reading lots of rows just takes some time. If you limit the columns you select and add those columns to the index (and...
Read more >
8 Tips and Tricks for Writing the Best Queries in LINQ to ...
This blog post provides a few tips and best practices to consider when writing LINQ to Entities to ensure they run quickly and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found