📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

1325 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

Indexes

Clustered, non-clustered, covering, composite, filtered and columnstore indexes, included columns, selectivity, fragmentation, fill factor and SARGability in SQL Server.

  1. Why does AddWithValue cause plan cache bloat as well as implicit conversions, and how do you detect it?

    Covers how SqlParameterCollection.AddWithValue infers nvarchar with the value's length, why that creates one cached plan per length and implicit conversions on varchar columns, and how to detect and fix it.

    Senior Debugging Indexes
  2. What is the difference between a clustered and a non-clustered index in SQL Server? Explain the B+ tree structure, what a heap is, and how SQL Server finds a row through each.

    Covers the B+ tree layout of SQL Server rowstore indexes, clustered indexes as the table itself, heaps and RIDs, non-clustered indexes and their row locators, and how seeks and lookups find a row.

    Junior Theory Indexes Β· πŸ”— 2 follow-ups
  3. You have a composite index on (CustomerId, OrderDate, Status) in SQL Server. Which queries can seek on it and which can't? Explain why column order matters, the leftmost-prefix rule, and how you decide the order of columns.

    Covers how a composite B+ tree index is sorted, the leftmost-prefix rule, equality-then-range column ordering, which predicates give seeks versus scans, and when to create a second index instead.

    Intermediate Theory Indexes Β· πŸ”— 2 follow-ups
  4. What is a covering index in SQL Server, and how do INCLUDE columns differ from key columns? What is a key lookup, when does it become a problem, and how do you decide whether to cover a query?

    Covers key lookups and RID lookups, covering indexes, INCLUDE versus key columns, the tipping point where the optimiser switches to a scan, and the write and storage cost of covering.

    Intermediate Theory Indexes Β· πŸ”— 2 follow-ups
  5. What is a filtered index in SQL Server and when would you use one, for example for soft-deleted rows or a status column? Explain the gotcha with parameterised queries, filtered unique indexes, and the other limitations you need to know.

    Covers filtered index syntax and use cases (soft delete, sparse status values, optional unique keys), why parameterised queries often cannot use them, the required SET options, filter predicate limits and filtered statistics.

    Mid-Level Theory Indexes Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  6. What are columnstore indexes in SQL Server? Explain rowgroups, segments, the delta store and batch mode, when you would put a non-clustered columnstore index on an OLTP table, and what it costs.

    Covers columnstore storage (rowgroups, column segments, compression, segment elimination), the delta store and tuple mover, batch mode execution, clustered versus non-clustered columnstore, real-time operational analytics and the trade-offs.

    Mid-Level Theory Indexes Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  7. What are selectivity and density in SQL Server? How do they relate to statistics and histograms, how does the optimiser use them to estimate rows, and why does it often ignore an index on a low-selectivity column?

    Covers selectivity and density definitions, the statistics object (header, density vector, 200-step histogram), how estimates are derived for literals, parameters and local variables, the seek-versus-scan tipping point, and when low-selectivity indexes are still useful.

    Mid-Level Theory Indexes Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  8. What is index fragmentation in SQL Server, and what does fill factor do? Explain page splits, logical fragmentation versus page density, rebuild versus reorganise, whether fragmentation still matters on SSDs and Azure SQL, and what index maintenance strategy you would actually run.

    Covers page splits, logical fragmentation and low page density, fill factor trade-offs, REBUILD versus REORGANIZE (online, resumable, statistics side effects), why fixed 5%/30% thresholds are outdated on SSD storage, and a measured maintenance strategy for SQL Server and Azure SQL.

    Mid-Level Theory Indexes Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  9. What does SARGable mean in SQL Server? Show me predicates that prevent an index seek, such as functions on columns, arithmetic, implicit conversions, leading wildcards and ISNULL, and rewrite each one so it can seek.

    Covers what makes a predicate SARGable, the common non-sargable patterns (functions and arithmetic on columns, implicit conversions, leading wildcards, ISNULL/COALESCE, OR across columns, catch-all queries) and their rewrites, including computed columns and the CAST to date exception.

    Mid-Level Sql Indexes Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  10. A lookup by account number has an index on a varchar(20) column, yet from your .NET API it scans the whole table and uses lots of CPU, while the same query typed into SSMS seeks instantly. The plan shows CONVERT_IMPLICIT. How do you diagnose it and fix it in EF Core, Dapper and ADO.NET?

    Covers how .NET strings become nvarchar parameters, why an nvarchar parameter against a varchar column converts the column and blocks seeks (collation nuances), finding it in plans and the plan cache, and fixing it with IsUnicode(false)/HasColumnType, DbString/AnsiString and typed SqlParameters.

    Senior Debugging Indexes Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  11. You own a write-heavy SQL Server table (orders, events or telemetry) that has accumulated a dozen indexes. How do you decide which indexes it should have? Explain the write cost of each index, how you find unused and missing indexes with DMVs, and the caveats of those DMVs.

    Covers the per-index write, log, memory and blocking cost, building an index set from real query patterns, finding unused indexes with sys.dm_db_index_usage_stats and missing indexes with the missing-index DMVs and Query Store, their caveats (resets, no column-order or write-cost awareness), safe removal by disabling first, and Azure SQL automatic tuning.

    Senior Theory Indexes Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me