EF Core 7 deadly sin

Load testing tool Bombardier https://github.com/codesenberg/bombardier   EF Core 7 deadly sin Get only the rows that you need Casting IQueryable -> IEnumerable use .Count() from IQueryable rather than IEnumerable, which will query all data and parsing all. Not using AsNoTracking Can be faster 4x times. Explicit joins Select and map to the object directly rather… Continue reading EF Core 7 deadly sin

DateTime – How to properly save and read date time in ASP.Net

There could be many ways of saving DateTime in an App. The simplest way is storing it as it is typed in by users if the website’s users are within a single country. If a website is serviced globally, confusion starts. Normally users might assume the date-time is local time. For example, if a user… Continue reading DateTime – How to properly save and read date time in ASP.Net

SQL query performance tuning

Tuning quick tips Getting the entire record before apply condition. -> Solution: Apply condition and paging before select. Using sub-query -> Solution: Turn it into join Using Table Variable being used with large data -> Solution: use Temp Table When a query performs badly, 3 things above are the most common causes I came across.… Continue reading SQL query performance tuning

SQL – Best way to get Total Count with pagination

Paginated query to SQL server is a very common logic that might be used literally everywhere. After googling a bit, the code below seems to be the best practice in 2020. The key point here is using Count(*) Over which allows getting list and total count at a single query. Select *, Count(*) Over ()… Continue reading SQL – Best way to get Total Count with pagination

C# Performance Improvement Experience

I have a personal code originally wriiten in 10 years ago when I was starting coding in University. The code is basically stock price analysis tool.  Recently I started to look at it again and found a few tips to improve the performance calculation and DB access heavy code. Actually, this shouldn’t be DB access… Continue reading C# Performance Improvement Experience