CROSS APPLY is the Ferrari of SQL join techniques.It looks fancy, and it really is. ποΈ β‘ Why CROSS APPLY Is Amazing π§ Lets you join custom row-by-row logic π Runs faster than correlated subqueries π Works great with TOP, aggregates & ranking πͺ Cleaner than temp tables SELECT u.Id, x.LastOrder FROM Users u CROSS […]
Day: December 5, 2025
Indexing Superpowers: The 5 Index Types Every Dev Should Know
Indexes arenβt magic ββ¦but they often look like magic when your query goes 40 sec β 20 ms. β‘ π 5 Index Types Everyone Should Know πΉ Clustered Index β defines table order πΉ Nonclustered Index β fast lookup πΉ Include Columns β covering index booster πΉ Filtered Index β tiny but powerful πΉ Columnstore […]
Parameter Sniffing β The #1 SQL Server Mystery You Must Understand
Parameter sniffing is NOT a bug.Itβs SQL Server being too smartβ¦ sometimes. π The Problem SQL caches a plan for one parameter and reuses it: EXEC GetOrdersByCustomer @customerId = 1; — cached plan EXEC GetOrdersByCustomer @customerId = 9999; — wrong plan reused β Symptoms Extreme slowdowns Terrible cardinality estimates βItβs fast for me but slow […]
Never Use SELECT * in Production β Hereβs Why It Destroys Performance
SELECT * feels convenientβ¦β¦but costs you RAM, CPU, network IO, and index usage. β Why SELECT * Is Dangerous π§± Prevents covering index usage π Sends unnecessary columns over network π Breaks when columns change π’ Slows down joins & scans — β Bad SELECT * FROM Orders; — β Good SELECT Id, OrderDate, Amount […]
The Hidden Killer: Scalar Functions β How to Avoid Massive Slowdowns
Scalar functions look innocentβ¦β¦until your query goes from 50 ms β 12 seconds. — β Never do this inside SELECT SELECT Id, dbo.GetUserScore(Id) FROM Users; π₯ Why Theyβre Slow β Executed row-by-row π« Breaks parallelism π Kills execution plans π Turns queries into RBAR (βRow By Agonizing Rowβ) β The Fix Use Inline Table-Valued Functions […]
Clean Dependency Injection β Lifetimes That Every Dev Must Master
β³ The 3 Lifetimes π΅ Singleton β stateless global services π’ Scoped β per-request (web default) π Transient β lightweight, multi-instance β Absolute Rule Never inject a Scoped service into a Singleton. Bad: builder.Services.AddSingleton<MyService>(); // depends on DbContext β β Correct Use factory: builder.Services.AddSingleton<MyService>(sp => new MyService(sp.GetRequiredService<IDbContextFactory<AppDb>>())); π§ Why? Prevents stale data Eliminates threading issues […]
EF Core: ExecuteUpdate & ExecuteDelete β Why You Should Stop Looping
The old way: foreach (var user in users) user.IsActive = false; await ctx.SaveChangesAsync(); The modern way: await ctx.Users.Where(x => x.IsActive) .ExecuteUpdateAsync(set => set.SetProperty(p => p.IsActive, false)); β‘ Benefits π Single SQL statement π§Ό No tracking overhead πΎ Saves CPU + DB roundtrips π§© Perfect for batch jobs + cron workers
C# Records β Why They Still Beat Classes for Domain Models
Records are still the cleanest way to model immutable domain data. public record Order(int Id, decimal Total, string Status); β€οΈ Why Devs Love Records π Built-in immutability π Value-based equality β Boilerplate goes to zero π Perfect for event-driven + DDD β‘ Extra Tip Use with expressions to clone deeply but safely.
.NET 9 Rate Limiting β Easy API Protection
Rate limiting used to be hardβ¦ now itβs literally one line. app.UseRateLimiter(new() { GlobalLimiter = PartitionedRateLimiter.CreateChained( PartitionedRateLimiter.CreateFixedWindow(10, TimeSpan.FromSeconds(5)) ) }); π Why You Need It π‘ Stops brute-force π Protects API throughput β Cloud-native resilience π Zero-config distributed support (Redis optional) π§ Bonus Pair with Minimal APIs for super-light API services.
Async Streams in C# β Clean, Fast, Real-Time Data
π Why Async Streams Shine Async Streams (IAsyncEnumerable<T>) are perfect for streaming data without memory blows. await foreach (var log in service.GetLogsAsync()) { Console.WriteLine(log); } β¨ What They Solve π Handling live logs π‘ Streamed API responses π§΅ Reducing memory spikes π Backpressure-friendly async flow π‘ Pro Tip Combine with channels for ultra-responsive pipelines.

