{"id":827,"date":"2026-08-13T06:56:43","date_gmt":"2026-08-13T06:56:43","guid":{"rendered":"https:\/\/online.jnujaipur.ac.in\/blogs\/?p=827"},"modified":"2026-08-14T07:55:36","modified_gmt":"2026-08-14T07:55:36","slug":"types-of-indexes-in-sql-server","status":"publish","type":"post","link":"https:\/\/online.jnujaipur.ac.in\/blogs\/types-of-indexes-in-sql-server\/","title":{"rendered":"Types of Indexes in SQL Server: All 12 Types Explained with Syntax (2026)"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">SQL Server supports twelve distinct index types: clustered, non-clustered, unique, filtered, clustered columnstore, non-clustered column store, hash, memory-optimized non-clustered, XML, spatial, full-text and vector. Each one solves a different retrieval problem. Choosing correctly is the difference between a query that returns in eight milliseconds and the same query returning in eight seconds.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Most articles on the types of indexes in SQL Server stop at six. They list clustered, non-clustered, unique, columnstore, filtered and full-text, then close with a paragraph about how indexes are like the index in a book. That was a complete answer in 2019. It is not a complete answer now. SQL Server 2025, released to general availability on 18 November 2025, added a native vector index built on Microsoft\u2019s DiskANN algorithm \u2014 the index type that makes semantic search and retrieval-augmented generation possible inside the database engine itself. Any guide that omits it is describing a product that no longer exists.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This guide covers all twelve, with working T-SQL syntax, the workload each one is designed for, the trade-off each one imposes, and a decision matrix you can apply to a real schema. It is written for BCA, MCA and Diploma in Data Science students who need this for a semester examination, and for working professionals who need it for a technical interview on Monday morning.<\/span><\/p>\n<h2><b>All 12 types of indexes in SQL Server at a glance<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Before the detail, here is the complete taxonomy in one view. Bookmark this table \u2014 it is the answer to the exam question &#8220;list the types of indexes in SQL Server.&#8221;<br \/>\n<\/span><\/p>\n<div style=\"width: 100%; overflow-x: auto; font-family: Arial, sans-serif;\">\n<table style=\"width: 100%; border-collapse: collapse; font-size: 15px; color: #374151;\">\n<thead>\n<tr style=\"background: #3f6289; color: #ffffff;\">\n<th style=\"border: 1px solid #b8c2cc; padding: 9px 8px; text-align: left;\">#<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 9px 8px; text-align: left;\">Index Type<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 9px 8px; text-align: left;\">Storage Model<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 9px 8px; text-align: left;\">Primary Use Case<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 9px 8px; text-align: left;\">Limit per Table<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">1<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Clustered<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Rowstore B-tree<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Range queries, ORDER BY, physical row order<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Exactly 1<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">2<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Non-clustered<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Rowstore B-tree<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Point lookups on non-key columns<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Up to 999<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">3<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Unique<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Rowstore B-tree<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Enforcing uniqueness plus fast lookup<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Multiple<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">4<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Filtered<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Rowstore B-tree<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Skewed columns, sparse or status subsets<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Multiple<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">5<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Clustered columnstore<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Column segments<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Data warehouse fact tables<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Exactly 1<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">6<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Non-clustered<br \/>\ncolumnstore<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Column segments<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Real-time analytics over OLTP tables<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Exactly 1<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">7<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Hash<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">In-memory<br \/>\nbuckets<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Equality-only lookups, In-Memory OLTP<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Multiple<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">8<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Memory-optimized<br \/>\nnon-clustered<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">In-memory<br \/>\nBw-tree<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Range scans on memory-optimized tables<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Multiple<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">9<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">XML<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Shredded node<br \/>\ntable<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">XQuery over XML columns<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">1 primary + 3<br \/>\nsecondary<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">10<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Spatial<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Tessellated grid<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Geometry and geography proximity queries<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Multiple<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">11<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Full-text<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Inverted word<br \/>\nindex<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Linguistic search with CONTAINS \/ FREETEXT<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Exactly 1<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">12<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Vector (SQL Server<br \/>\n2025)<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">DiskANN graph<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Semantic search, RAG, nearest-neighbour<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 9px 8px;\">Multiple<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><span style=\"font-weight: 400;\">Know More: <\/span><strong><a href=\"https:\/\/online.jnujaipur.ac.in\/blogs\/best-bca-online-colleges-in-india-7-point-checklist\/\" target=\"_blank\" rel=\"noopener\">Best BCA Online Colleges in India (2026): The 7-Point Checklist to Choose the Right One<\/a><\/strong><\/p>\n<h2><b>What is an index in SQL Server, and why does it change everything?<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">An index is a separate, ordered data structure that lets the SQL Server query optimizer locate rows without reading every page in the table.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Without an index, SQL Server performs a <\/span>table scan: it reads all 8 KB data pages belonging to the table and discards the rows that do not match. On a 50-million-row orders table, that is millions of page reads for a query that returns four rows.<\/p>\n<p>With a suitable index, SQL Server performs an index seek<span style=\"font-weight: 400;\">: it navigates a B-tree from the root page down through intermediate levels to the exact leaf page holding the matching rows. Three or four page reads instead of millions.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A table with no clustered index is called a <\/span>heap. Rows sit in no guaranteed order, and the only way to find anything is to scan. A table with a clustered index is called a clustered table, and its rows are stored in the logical order of the index key.<\/p>\n<p>Two terms you must be able to distinguish in any interview:<\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Index seek<\/b><span style=\"font-weight: 400;\"> \u2014 the optimizer navigates directly to the qualifying rows. This is what you want.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Index scan<\/b><span style=\"font-weight: 400;\"> \u2014 the optimizer reads every leaf page of the index. Better than a table scan, but it usually signals a missing or badly ordered index.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">A third term decides whether your index actually helps: <\/span>key lookup<span style=\"font-weight: 400;\">. When a non-clustered index contains the search column but not the columns in your SELECT list, SQL Server must jump back to the clustered index for every matching row. On a query returning 40,000 rows, that is 40,000 extra lookups, and the optimizer will frequently abandon your index altogether and scan the table instead. Solving key lookups is what included columns exist for, and we return to them below.<\/span><\/p>\n<h2><b>The four rowstore SQL Server index types you will be tested on<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Rowstore indexes store data row by row in a B-tree structure. These are the four that appear in almost every syllabus and almost every interview.<\/span><\/p>\n<h3><b>1. Clustered index<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A clustered index determines the physical storage order of the rows in a table. The leaf level of the index <\/span><i><span style=\"font-weight: 400;\">is<\/span><\/i><span style=\"font-weight: 400;\"> the table data \u2014 there is no separate copy. Because rows can only be sorted one way, <\/span>a table can have exactly one clustered index<span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CREATE CLUSTERED INDEX IX_Orders_OrderDate<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ON dbo.Orders (OrderDate);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When you declare a PRIMARY KEY, SQL Server creates a clustered index on that column by default unless you specify NONCLUSTERED. That default is a convenience, not a recommendation \u2014 the best clustered key is narrow, unique, static and ever-increasing, which is why an identity column or a date column often outperforms a natural key.<\/span><\/p>\n<p><b>Best for:<\/b><span style=\"font-weight: 400;\"> range queries (BETWEEN, &gt;=, &lt;=), ORDER BY on the key column, and as the anchor for every non-clustered index on the table.<\/span><\/p>\n<p><b>Cost:<\/b><span style=\"font-weight: 400;\"> every insert into the middle of the key range can cause page splits, which fragment the index and slow writes.<\/span><\/p>\n<h3><b>2. Non-clustered index<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A non-clustered index is a separate structure that holds the key columns in sorted order plus a <\/span>row locator<span style=\"font-weight: 400;\"> pointing back to the actual data \u2014 the clustered index key if the table is clustered, or a physical row identifier (RID) if it is a heap. A single table supports up to <\/span>999 non-clustered indexes, though a schema needing more than a handful is usually a schema with a design problem.<\/p>\n<p><span style=\"font-weight: 400;\">CREATE NONCLUSTERED INDEX IX_Orders_CustomerID<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ON dbo.Orders (CustomerID)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0INCLUDE (OrderDate, TotalAmount);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The INCLUDE clause is the single most underused feature in SQL Server indexing. Included columns are stored only at the leaf level, are not part of the sort key, and do not count against the 1,700-byte key size limit. Adding the columns your query returns turns the index into a <\/span>covering index<span style=\"font-weight: 400;\">: SQL Server answers the entire query from the index and never touches the base table. No key lookups, no table access, dramatically fewer reads.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Understanding the difference between a <\/span>clustered and non-clustered index<span style=\"font-weight: 400;\"> is the most frequently asked SQL Server interview question at every experience level, so be precise: the clustered index <\/span><i><span style=\"font-weight: 400;\">is<\/span><\/i><span style=\"font-weight: 400;\"> the data, sorted; the non-clustered index is a pointer structure <\/span><i><span style=\"font-weight: 400;\">to<\/span><\/i><span style=\"font-weight: 400;\"> the data.<\/span><\/p>\n<h3><b>3. Unique index<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A unique index enforces that no two rows share the same value in the indexed column or column combination. It serves two purposes at once \u2014 data integrity and query performance \u2014 because the optimizer knows it will find at most one matching row.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CREATE UNIQUE NONCLUSTERED INDEX UX_Students_Email<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ON dbo.Students (Email);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A UNIQUE constraint and a unique index are implemented identically by the engine; the constraint is the declarative form, the index is the physical form. A unique index can be clustered or non-clustered, and it can span multiple columns, in which case the <\/span><i><span style=\"font-weight: 400;\">combination<\/span><\/i><span style=\"font-weight: 400;\"> must be unique rather than each column individually.<\/span><\/p>\n<h3><b>4. Filtered index<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A <\/span>filtered index in SQL Server<span style=\"font-weight: 400;\"> is a non-clustered index defined with a WHERE clause, so it covers only a subset of rows. Because the structure is smaller, it is cheaper to store, faster to scan and cheaper to maintain.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CREATE NONCLUSTERED INDEX IX_Orders_Pending<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ON dbo.Orders (CustomerID, OrderDate)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0WHERE OrderStatus = &#8216;Pending&#8217;;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The classic use case for a filtered index in SQL Server is a status column with skewed distribution \u2014 2% of orders pending, 98% completed. A full index on OrderStatus is nearly useless because the column has terrible selectivity. A filtered index covering only pending orders is small, highly selective and used constantly.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Two caveats that examiners like: a filtered index in SQL Server is non-clustered only, and the query\u2019s WHERE clause must be logically compatible with the index filter for the optimizer to use it. SET options such as ANSI_NULLS and QUOTED_IDENTIFIER must also be correctly configured on the connection.<\/span><\/p>\n<h2><b>Clustered vs non-clustered vs unique vs filtered<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Among all the types of indexes in SQL Server, these four are the ones an examiner will almost certainly ask you to compare. This table answers that question directly.<\/span><\/p>\n<div style=\"width: 100%; overflow-x: auto; font-family: Arial, sans-serif;\">\n<table style=\"width: 100%; border-collapse: collapse; font-size: 15px; color: #374151; min-width: 850px;\">\n<thead>\n<tr style=\"background: #3f6289; color: #ffffff;\">\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Attribute<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Clustered Index<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Non-Clustered Index<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Unique Index<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Filtered Index<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">What it stores<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">The table data itself, in key order<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Key values plus a row locator<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Key values, duplicates rejected<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Key values for a row subset only<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Per table<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Exactly one<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Up to 999<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Multiple permitted<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Multiple permitted<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Extra storage<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">None \u2014 it is the table<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Yes, a separate structure<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Yes, unless clustered<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Yes, but small<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Read speed<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Fastest for ranges<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Fast for point lookups<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Fastest for single-row hits<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Very fast on the filtered subset<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Write cost<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Page splits on mid-range inserts<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Updated on every relevant write<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Adds a uniqueness check<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Lowest of the four<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Enforces integrity<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Only if declared unique<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">No<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Yes<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Only if declared unique<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Typical trigger<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Primary key or date column<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Frequent WHERE or JOIN column<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Email, PAN, enrolment number<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">WHERE Status = &#8216;Pending&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2><b>Columnstore indexes: the analytics engine<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Everything above stores data row by row. A <\/span>columnstore index in SQL Server<span style=\"font-weight: 400;\"> inverts that: it stores each column separately, compresses it, and processes queries in batch mode rather than row by row. Microsoft\u2019s published guidance puts the gain at up to 10x data compression and up to 100x query performance for analytical workloads compared with equivalent rowstore storage.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The reason is straightforward. An analytical query such as SELECT Region, SUM(Revenue) FROM Sales GROUP BY Region touches two columns out of forty. Rowstore reads all forty because rows are stored intact. Columnstore reads two. Compression is also far higher because values within a single column are similar to one another \u2014 a Region column with eight distinct values across ten million rows compresses enormously.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">There are two variants:<\/span><\/p>\n<p><b>Clustered columnstore index<\/b><span style=\"font-weight: 400;\"> \u2014 this <\/span><i><span style=\"font-weight: 400;\">is<\/span><\/i><span style=\"font-weight: 400;\"> the table\u2019s storage. The entire table is held in column format. Use it for fact tables and data warehouse tables that are read far more often than they are updated.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CREATE CLUSTERED COLUMNSTORE INDEX CCI_FactSales<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ON dbo.FactSales;<\/span><\/p>\n<p><b>Non-clustered columnstore index<\/b><span style=\"font-weight: 400;\"> \u2014 a secondary columnstore index in SQL Server that sits on top of a normal rowstore table. This is the key to hybrid transactional\/analytical processing: the rowstore serves your OLTP writes, the columnstore serves your reports, and both stay current.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CREATE NONCLUSTERED COLUMNSTORE INDEX NCCI_Orders<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ON dbo.Orders (OrderDate, ProductID, Quantity, TotalAmount);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Rows are organised into <\/span>rowgroups<span style=\"font-weight: 400;\"> of roughly one million rows, and each column segment within a rowgroup is compressed independently. Rowgroups that are too small \u2014 the result of trickle inserts \u2014 degrade performance badly, which is why bulk loading into a columnstore index in SQL Server is preferred over row-by-row insertion.<br \/>\n<\/span><\/p>\n<div style=\"width: 100%; overflow-x: auto; font-family: Arial, sans-serif;\">\n<table style=\"width: 100%; min-width: 850px; border-collapse: collapse; font-size: 15px; color: #374151;\">\n<thead>\n<tr style=\"background: #3f6289; color: #ffffff;\">\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Comparison Point<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Rowstore (Clustered \/<br \/>\nNon-clustered)<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Columnstore (Clustered \/<br \/>\nNon-clustered)<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Memory-Optimized (Hash<br \/>\n\/ Bw-tree)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Storage layout<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Row by row across 8 KB pages<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Column by column in compressed segments<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">In memory, no data pages<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Execution mode<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Row mode<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Batch mode<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Row mode, latch-free<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Compression<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Optional page or row compression<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Very high \u2014 similar values grouped together<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">None; memory resident<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Ideal workload<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">OLTP \u2014 inserts, updates, point lookups<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">OLAP \u2014 aggregations and scans over millions of rows<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Extreme-throughput OLTP<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Weak at<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Large aggregate scans<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Single-row seeks and frequent trickle inserts<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Durability tuning and memory ceilings<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Range queries<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Yes<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Yes, via segment elimination<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Bw-tree yes, hash no<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Typical example<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Fetch one student record by roll number<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Total revenue by region for the year<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Session or token cache lookups<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2><b>Memory-optimized indexes: hash and Bw-tree<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">These two exist only on memory-optimized tables (In-Memory OLTP). They live in memory, contain no data pages, and are rebuilt from the durable data at database startup.<\/span><\/p>\n<h3><b>5. Hash index<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A hash index applies a hash function to the key and maps it to a <\/span>bucket<span style=\"font-weight: 400;\">. Point lookups become close to O(1) \u2014 the fastest single-row retrieval SQL Server offers.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CREATE TABLE dbo.SessionCache (<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0SessionID\u00a0 INT \u00a0 \u00a0 \u00a0 NOT NULL PRIMARY KEY NONCLUSTERED<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0HASH WITH (BUCKET_COUNT = 1000000),<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0UserID \u00a0 \u00a0 INT \u00a0 \u00a0 \u00a0 NOT NULL,<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0LastSeen \u00a0 DATETIME2 NOT NULL<\/span><\/p>\n<p><span style=\"font-weight: 400;\">) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The critical parameter is BUCKET_COUNT. Set it too low and multiple keys collide into one bucket, forming long chains that destroy performance. Microsoft\u2019s guidance is to set it to roughly one to two times the number of distinct key values. The hard limitation: a hash index supports <\/span>equality predicates only<span style=\"font-weight: 400;\">. It cannot serve a range query or an ORDER BY, because hashing destroys ordering.<\/span><\/p>\n<h3><b>6. Memory-optimized non-clustered index<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Also called a Bw-tree index, this is the range-capable counterpart. It supports inequality predicates, BETWEEN and ordered scans on memory-optimized tables \u2014 everything a hash index cannot do.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">ALTER TABLE dbo.SessionCache<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ADD INDEX IX_SessionCache_LastSeen NONCLUSTERED (LastSeen);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Rule of thumb: hash for equality-only lookups where you know the cardinality; Bw-tree for everything else, including when you are unsure of the distribution.<\/span><\/p>\n<h2><b>Specialised SQL Server index types: XML, spatial and full-text<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">These three SQL Server index types are domain-specific. Students routinely skip them and then meet them in an interview.<\/span><\/p>\n<h3><b>7. XML index<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Querying an XML column with XQuery without an index forces SQL Server to shred the entire XML document at runtime, every time. A <\/span>primary XML index<span style=\"font-weight: 400;\"> stores a pre-shredded representation of the document. Once it exists, you can add up to three <\/span>secondary XML indexes<span style=\"font-weight: 400;\"> \u2014 PATH, VALUE and PROPERTY \u2014 each tuned to a different query shape.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CREATE PRIMARY XML INDEX PXML_Students_Details<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ON dbo.Students (StudentDetails);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CREATE XML INDEX SXML_Students_Path<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ON dbo.Students (StudentDetails)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0USING XML INDEX PXML_Students_Details FOR PATH;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The table must already have a clustered primary key. A primary XML index typically consumes a substantial multiple of the base XML data size, so treat it as a considered decision rather than a default.<\/span><\/p>\n<h3><b>8. Spatial index<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A spatial index accelerates queries over geometry and geography data \u2014 proximity searches, containment checks, distance calculations. SQL Server decomposes space into a four-level tessellated grid and indexes cell membership in a B-tree.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CREATE SPATIAL INDEX SIX_Campus_Location<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ON dbo.Campus (LocationGeo)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0USING GEOGRAPHY_AUTO_GRID;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Any application answering &#8220;which branches are within five kilometres of this pin&#8221; depends on this index type.<\/span><\/p>\n<h3><b>9. Full-text index<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A full-text index enables linguistic search across large character columns: word forms, thesaurus expansion, proximity and inflectional matching, through the CONTAINS and FREETEXT predicates. LIKE with a leading wildcard cannot use a standard B-tree index at all and degrades linearly with table size; full-text search does not.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CREATE FULLTEXT INDEX ON dbo.Articles (Body LANGUAGE 1033)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0KEY INDEX UX_Articles_ID<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ON ftCatalog<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0WITH CHANGE_TRACKING AUTO;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A table supports only one full-text index, and it requires an existing unique, single-column, non-nullable index as its key.<\/span><\/p>\n<h2><b>10, 11 and 12: vector indexes and the AI-era additions<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">This is the section the competing articles do not have, and it is the reason this guide exists.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">SQL Server 2025 (version 17.x, compatibility level 170) introduced a native VECTOR data type for storing embeddings, and with it a <\/span>vector index<span style=\"font-weight: 400;\"> built on <\/span>DiskANN<span style=\"font-weight: 400;\"> \u2014 a graph-based approximate nearest neighbour algorithm developed by Microsoft Research that leverages SSD storage to index far more vectors than an in-memory structure could hold, while sustaining high queries per second.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CREATE VECTOR INDEX VI_Articles_Embedding<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0ON dbo.Articles (BodyEmbedding)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0WITH (METRIC = &#8216;cosine&#8217;, TYPE = &#8216;diskann&#8217;);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Queries then use the VECTOR_SEARCH function to run approximate nearest-neighbour searches. The metric can be cosine, euclidean or dot, depending on how your embedding model was trained.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Three practical notes, because accuracy matters more than hype:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The VECTOR data type and VECTOR_DISTANCE reached general availability. CREATE VECTOR INDEX and VECTOR_SEARCH shipped as <\/span>preview features<span style=\"font-weight: 400;\"> in SQL Server 2025 and require ALTER DATABASE SCOPED CONFIGURATION SET PREVIEW_FEATURES = ON. Microsoft does not recommend preview features for production.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Vector indexes require a minimum row count before creation \u2014 roughly 100 rows in current builds.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Exact search with VECTOR_DISTANCE remains correct and is often faster below roughly 50,000 candidate vectors. The index earns its place above that threshold.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">This is also why vector search now sits alongside model training in <a href=\"https:\/\/online.jnujaipur.ac.in\/online-diploma-ai-ml\" target=\"_blank\" rel=\"noopener\"><strong>applied AI and machine learning<\/strong><\/a> curricula rather than in a specialist elective.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Why this belongs in a discussion of the types of indexes in SQL Server rather than in a separate AI article: it means a retrieval-augmented generation pipeline no longer requires a bolted-on vector database. Embeddings, relational data, joins and security all live in one engine, under one backup policy and one permission model. For a student building a final-semester project, that is a materially simpler architecture.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The remaining two entries in the taxonomy of twelve are the <\/span>clustered and non-clustered columnstore<span style=\"font-weight: 400;\"> variants counted separately above, since Microsoft treats them as distinct index objects with different storage semantics.<\/span><\/p>\n<p>Read More<strong>\u00a0:<\/strong> <a href=\"https:\/\/online.jnujaipur.ac.in\/blogs\/bca-vs-btech\/\" target=\"_blank\" rel=\"noopener\"><strong>BCA or BTech: Which Course Should You Choose After Class 12?<\/strong><\/a><\/p>\n<h2><b>Which index should you actually create? A decision matrix<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Listing SQL Server index types is the easy half. Choosing between them under a real workload is what separates a graduate who can answer the exam question from one who can do the job.<\/span><\/p>\n<div style=\"width: 100%; overflow-x: auto; font-family: Arial, sans-serif;\">\n<table style=\"width: 100%; min-width: 850px; border-collapse: collapse; font-size: 15px; color: #374151;\">\n<thead>\n<tr style=\"background: #3f6289; color: #ffffff;\">\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">If your query looks like this&#8230;<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Create this index<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Why<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">WHERE OrderDate BETWEEN &#8230; AND &#8230;<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Clustered index on OrderDate<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Rows are already physically ordered, so the range is a contiguous read<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">WHERE CustomerID = @id, returning 3 columns<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Non-clustered on CustomerID with INCLUDE on the 3 columns<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Covering index removes the key lookup entirely<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">WHERE Status = &#8216;Pending&#8217; on a skewed column<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Filtered index with a matching WHERE clause<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Indexes only the 2% of rows that are actually queried<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Email must never repeat<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Unique non-clustered index<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Enforces integrity and guarantees at most one matching row<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">SUM \/ GROUP BY over millions of rows<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Clustered columnstore (warehouse) or non-clustered columnstore (live OLTP)<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Column segments plus batch mode cut I\/O by an order of magnitude<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Single-row equality on a memory-optimized table<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Hash index with tuned BUCKET_COUNT<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Close to O(1) lookup; no ordering available<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Range scan on a memory-optimized table<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Memory-optimized non-clustered (Bw-tree)<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Hash indexes cannot serve ranges or ORDER BY<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">XQuery against an XML column<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Primary XML index, then PATH \/ VALUE \/ PROPERTY<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Avoids shredding the document on every execution<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Branches within 5 km of a point<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Spatial index on the geography column<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Grid tessellation prunes candidate cells before evaluation<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Word-form or thesaurus search in long text<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Full-text index with CONTAINS or FREETEXT<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">LIKE with a leading wildcard cannot use a B-tree<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Find semantically similar documents or embeddings<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Vector index using DiskANN<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Approximate nearest-neighbour search over embeddings<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Small lookup table under a few hundred rows<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">No index<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">A scan of a handful of pages beats index overhead<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><span style=\"font-weight: 400;\">Work through it in this order:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Read the execution plan first.<span style=\"font-weight: 400;\"> Never create an index from intuition. Look for Table Scan, Clustered Index Scan and Key Lookup operators.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Put the most selective column first<span style=\"font-weight: 400;\"> in a composite key. Column order in a composite index is not cosmetic \u2014 an index on (LastName, City) serves a query filtering on LastName alone, but not one filtering on City alone.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Cover the query with INCLUDE<span style=\"font-weight: 400;\"> rather than widening the key.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\">Verify the improvement.<span style=\"font-weight: 400;\"> Compare logical reads before and after with SET STATISTICS IO ON.<\/span><\/li>\n<\/ol>\n<p>Know More<strong>\u00a0:<\/strong> <a href=\"https:\/\/online.jnujaipur.ac.in\/blogs\/software-developer-after-bca\/\" target=\"_blank\" rel=\"noopener\"><strong>How to Become a Software Developer After BCA: Skills, Courses, and Career Path<\/strong><\/a><\/p>\n<h2><b>When you should not create an index<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Indexes are not free. Every index must be updated on every INSERT, UPDATE and DELETE that touches its columns. An over-indexed OLTP table can write more slowly than an unindexed one.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Avoid indexing when:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The table is small \u2014 a few hundred rows fit in a handful of pages and scan faster than a seek.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The column has low <\/span>selectivity<span style=\"font-weight: 400;\">. A gender or boolean column with two distinct values across a million rows will be ignored by the optimizer.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The table is write-heavy and the index is rarely read.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The index duplicates an existing one. (CustomerID) is redundant if (CustomerID, OrderDate) already exists, because the leading column is already covered.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Find indexes nobody uses with the usage statistics DMV:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">SELECT OBJECT_NAME(s.object_id) AS TableName,<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0i.name AS IndexName,<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0s.user_seeks, s.user_scans, s.user_lookups, s.user_updates<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FROM \u00a0 sys.dm_db_index_usage_stats AS s<\/span><\/p>\n<p><span style=\"font-weight: 400;\">JOIN \u00a0 sys.indexes AS i<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ON i.object_id = s.object_id AND i.index_id = s.index_id<\/span><\/p>\n<p><span style=\"font-weight: 400;\">WHERE\u00a0 s.database_id = DB_ID()<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0AND\u00a0 s.user_seeks + s.user_scans + s.user_lookups = 0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">ORDER BY s.user_updates DESC;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Any index with zero reads and high user_updates is pure overhead. Drop it.<\/span><\/p>\n<h2><b>Index maintenance in one paragraph<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Indexes fragment as pages split. The widely used threshold, drawn from Microsoft\u2019s own guidance, is to REORGANIZE between roughly 5% and 30% average fragmentation and REBUILD above 30%. Check with sys.dm_db_index_physical_stats. FILLFACTOR controls how much free space each leaf page reserves at build time \u2014 leave it at the default for read-mostly tables, lower it to 80\u201390 for tables with heavy mid-range inserts. And keep statistics current, because the optimizer chooses between your indexes using statistics, not the indexes themselves.<\/span><\/p>\n<h2><b>Six interview questions on SQL Server indexes, answered<\/b><\/h2>\n<h2><b style=\"font-size: 16px;\">Q. Explain the difference between a clustered and non-clustered index.<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">The clustered index is the table data held in key order. The non-clustered index is a separate structure of key values and row locators pointing at that data. One clustered index per table; up to 999 non-clustered.<\/span><\/p>\n<p><b>Q. How many clustered indexes can a table have, and why?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">One. The clustered index defines the physical order of the rows, and rows can only be physically ordered one way.<\/span><\/p>\n<p><b>Q. What is the difference between an index seek and an index scan?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">A seek navigates the B-tree directly to the qualifying rows. A scan reads every leaf page. A scan on a large table usually means the index is missing, badly ordered, or the predicate is not sargable.<\/span><\/p>\n<p><b>Q. What is a covering index?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">A non-clustered index containing every column the query needs, either as key columns or via INCLUDE, so the query is satisfied without touching the base table.<\/span><\/p>\n<p><b>Q. When would you use a columnstore index over a rowstore index?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Use a columnstore index in SQL Server for analytical queries that aggregate a few columns across many rows. Rowstore suits OLTP point lookups and updates; columnstore suits scans, aggregations and reporting.<\/span><\/p>\n<p><b>Q. What is new in SQL Server 2025 indexing?<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Native vector indexes using the DiskANN algorithm, enabling approximate nearest-neighbour search over embeddings through CREATE VECTOR INDEX and VECTOR_SEARCH, currently as preview features.<\/span><\/p>\n<h2><b>Where you learn this properly: database papers at JNU Online<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Reading a guide gets you through an interview round. Building and breaking indexes on a real database is what makes the knowledge stick, and that requires a structured programme with laboratory credits rather than a video playlist.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Jaipur National University delivers its online and distance programmes through its <a href=\"https:\/\/online.jnujaipur.ac.in\/recognition\" target=\"_blank\" rel=\"noopener\"><strong>Centre for Distance and Online Education<\/strong><\/a>. The university holds UGC recognition under Section 2(f), UGC-DEB entitlement for its online programmes, NAAC A+ accreditation and Association of Indian Universities membership \u2014 every approval document is published for public inspection on the <strong><a href=\"https:\/\/online.jnujaipur.ac.in\/\" target=\"_blank\" rel=\"noopener\">JNU Online website<\/a>,<\/strong> which is the verification step every applicant should complete before paying any fee.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Three JNU Online programmes carry database papers with dedicated laboratory credits, which is where indexing is actually practised rather than merely read about.<\/span><\/p>\n<div style=\"width: 100%; overflow-x: auto; font-family: Arial, sans-serif;\">\n<table style=\"width: 100%; min-width: 850px; border-collapse: collapse; font-size: 15px; color: #374151;\">\n<thead>\n<tr style=\"background: #3f6289; color: #ffffff;\">\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">JNU Online Programme<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Duration<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Total Fee (India)<\/th>\n<th style=\"border: 1px solid #b8c2cc; padding: 10px; text-align: left;\">Database Papers Carrying Lab Credits<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Online MCA<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">2 years<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">\u20b91,06,400<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Database Management System + Lab (Sem I);<br \/>\nAdvanced Database Concepts + Lab (Sem III)<\/td>\n<\/tr>\n<tr style=\"background: #e9edf2;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Online BCA<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">3 years<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">\u20b91,04,160<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Database Management System + Lab (Sem II);<br \/>\nMySQL (SQL\/PL-SQL) + Project Lab (Sem III)<\/td>\n<\/tr>\n<tr style=\"background: #f7f7f7;\">\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Online Diploma in Data<br \/>\nScience<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">1 year<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Published on<br \/>\nenquiry<\/td>\n<td style=\"border: 1px solid #c9d1d9; padding: 10px;\">Database Management Systems + Lab (Sem I); Big<br \/>\nData Analytics + Lab (Sem II)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><span style=\"font-weight: 400;\">A few specifics worth knowing:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The <\/span><a href=\"https:\/\/online.jnujaipur.ac.in\/online-mca\" target=\"_blank\" rel=\"noopener\"><strong>Online MCA<\/strong><\/a><span style=\"font-weight: 400;\"> teaches Database Management System as a core paper in Semester I with an accompanying laboratory, then returns to the subject in Semester III with <\/span>Advanced Database Concepts<span style=\"font-weight: 400;\"> as a discipline-specific elective plus a dedicated laboratory. Semester III also offers Big Data Analytics and Cloud Computing as electives \u2014 directly relevant if columnstore and vector indexing interest you. The final semester carries 20 credits of industrial training and 5 credits for a research paper publication.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The <\/span><a href=\"https:\/\/online.jnujaipur.ac.in\/online-bca\" target=\"_blank\" rel=\"noopener\"><strong>Online BCA<\/strong><\/a><span style=\"font-weight: 400;\"> covers Database Management System with a laboratory in Semester II, then moves to hands-on query writing in Semester III through <\/span>MySQL (SQL\/PL-SQL)<span style=\"font-weight: 400;\"> with a project-based laboratory, and reaches Data Warehousing and Data Mining in Semester V.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The <\/span><a href=\"https:\/\/online.jnujaipur.ac.in\/online-diploma-data-science\" target=\"_blank\" rel=\"noopener\"><b>Online Diploma in Data Science<\/b><\/a><span style=\"font-weight: 400;\"> is the fastest route for someone who already holds a degree or simply wants the skill. Database Management Systems with a laboratory sits in Semester I, followed by Big Data Analytics, Data Analysis Using Python and a capstone project in Semester II across 34 total credits.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">MCA eligibility is a bachelor\u2019s degree of at least three years in any stream with at least 40% marks and Mathematics as a subject; candidates who did not study Mathematics at graduation level complete a bridge programme first. BCA and the Diploma in Data Science require 10+2 with 40% marks. Admission is on merit, with no entrance examination.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you are still deciding between qualifications, our comparison of MSc Computer Science vs MCA sets the two degrees side by side on eligibility, syllabus and online availability. If you are at the undergraduate stage instead, the seven-point checklist for choosing BCA online colleges covers exactly what to verify before applying, and the guide to UGC-approved online degree courses in India walks through the DEB-ID process step by step.<\/span><\/p>\n<h2><b>Conclusion<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">The complete set of types of indexes in SQL Server is twelve, not six: four rowstore structures, two columnstore variants, two memory-optimized structures, three specialised indexes for XML, spatial and full-text data, and one vector index for the AI workloads that arrived with SQL Server 2025.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Memorising the list gets you a mark in an examination. What gets you hired is the reasoning underneath it \u2014 reading an execution plan, recognising a key lookup, knowing that a filtered index beats a full index on a skewed column, and knowing that an index nobody reads is a tax on every write.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Start with the execution plan, index the predicate, cover the SELECT list, and measure. Then verify your qualification the same way you verify an index: check it against the source. For any online degree in India, that means the <a href=\"https:\/\/online.jnujaipur.ac.in\/recognition\" target=\"_blank\" rel=\"noopener\"><strong>UGC-DEB entitlement list<\/strong><\/a> for your intake year.<\/span><\/p>\n<h2><b>Frequently Asked Questions<\/b><\/h2>\n<h3><b>How many types of indexes are there in SQL Server?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">There are twelve types of indexes in SQL Server: clustered, non-clustered, unique, filtered, clustered columnstore, non-clustered columnstore, hash, memory-optimized non-clustered, XML, spatial, full-text and vector. Older guides list six because they predate the columnstore, memory-optimized and vector additions.<\/span><\/p>\n<h3><b>What is the main difference between a clustered and non-clustered index?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A clustered and non-clustered index differ in what they store. A clustered index stores the table rows themselves in key order, so a table can have only one. A non-clustered index is a separate structure holding key values plus pointers back to the rows, and a table can have up to 999.<\/span><\/p>\n<h3><b>Can a table have more than one clustered index?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">No. Rows can be physically ordered only one way. A table without a clustered index is called a heap.<\/span><\/p>\n<h3><b>Which index type is fastest in SQL Server?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">There is no fastest index type in the abstract. A hash index gives the fastest single-row equality lookup, a clustered index is fastest for range scans, and a columnstore index is fastest for aggregations over millions of rows. The fastest index is the one matching your query pattern.<\/span><\/p>\n<h3><b>What is a covering index?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A non-clustered index that contains every column a query requires, using key columns plus the INCLUDE clause, so SQL Server never needs to read the base table.<\/span><\/p>\n<h3><b>Do indexes slow down INSERT and UPDATE operations?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Yes. Every index must be maintained on every write that touches its columns. This is why unused indexes should be identified through sys.dm_db_index_usage_stats and dropped.<\/span><\/p>\n<h3><b>What is a vector index in SQL Server 2025?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">A DiskANN-based graph index over VECTOR columns that enables approximate nearest-neighbour search for semantic search and retrieval-augmented generation. It is created with CREATE VECTOR INDEX and queried with VECTOR_SEARCH, and ships as a preview feature requiring PREVIEW_FEATURES to be enabled.<\/span><\/p>\n<h3><b>Is a unique index the same as a primary key?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Not quite. A primary key creates a unique index and additionally enforces NOT NULL, and there can be only one per table. A unique index permits a single NULL value and a table can have many.<\/span><\/p>\n<h3><b>Which JNU Online programme teaches SQL and database indexing?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">The Online MCA covers Database Management System in Semester I and Advanced Database Concepts in Semester III, both with laboratories. The Online BCA covers Database Management System in Semester II and MySQL (SQL\/PL-SQL) in Semester III. The Online Diploma in Data Science covers Database Management Systems with a laboratory in Semester I.<\/span><\/p>\n<p><strong>Follow Us<\/strong>:\u00a0<a href=\"https:\/\/www.facebook.com\/OnlineJNU\/\" target=\"_blank\" rel=\"noopener\">Facebook<\/a>\u00a0|\u00a0<a href=\"https:\/\/www.instagram.com\/jnu.online\/\" target=\"_blank\" rel=\"noopener\">Instagram<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL Server supports twelve distinct index types: clustered, non-clustered, unique, filtered, clustered columnstore, non-clustered column&#8230;<\/p>\n","protected":false},"author":1,"featured_media":828,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[7,5],"tags":[219],"class_list":["post-827","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-online-bca","category-online-mca","tag-types-of-indexes-in-sql-server","entry"],"acf":[],"_links":{"self":[{"href":"https:\/\/online.jnujaipur.ac.in\/blogs\/wp-json\/wp\/v2\/posts\/827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/online.jnujaipur.ac.in\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/online.jnujaipur.ac.in\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/online.jnujaipur.ac.in\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/online.jnujaipur.ac.in\/blogs\/wp-json\/wp\/v2\/comments?post=827"}],"version-history":[{"count":1,"href":"https:\/\/online.jnujaipur.ac.in\/blogs\/wp-json\/wp\/v2\/posts\/827\/revisions"}],"predecessor-version":[{"id":829,"href":"https:\/\/online.jnujaipur.ac.in\/blogs\/wp-json\/wp\/v2\/posts\/827\/revisions\/829"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/online.jnujaipur.ac.in\/blogs\/wp-json\/wp\/v2\/media\/828"}],"wp:attachment":[{"href":"https:\/\/online.jnujaipur.ac.in\/blogs\/wp-json\/wp\/v2\/media?parent=827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/online.jnujaipur.ac.in\/blogs\/wp-json\/wp\/v2\/categories?post=827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/online.jnujaipur.ac.in\/blogs\/wp-json\/wp\/v2\/tags?post=827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}