liveBook · Manning

Nonclustered index

As explained in Learn SQL in a Month of Lunches

A nonclustered index is a separate database object that stores an ordering or lookup path for table rows without defining the table's physical order.

A nonclustered index is a separate database object that provides another ordering or lookup path to table rows. Unlike a clustered index, it does not determine the table’s physical order, so one table can have several nonclustered indexes. section 19.3.2 section 19.3

Think of a library catalog: search by a book’s title, find its numeric location, then go to the shelf. A nonclustered index similarly finds matching values and points toward the table rows, avoiding an unnecessary scan of the entire table. section 19.3.2

Speeding a shipment-date report

A report counting shipments for one date can use an index on ShipmentDate: CREATE INDEX IX_shipment_ShipmentDate ON shipment (ShipmentDate); The index helps locate the relevant date instead of reading the entire shipment table. Keep indexes focused: extra columns consume storage and add work to INSERT, UPDATE, and DELETE operations. section 19.5 section 19.3.2

CREATE INDEX IX_shipment_TrackingNumber ON shipment (TrackingNumber);

Inspect a complete CREATE INDEX statement for a shipment tracking number. section 19.3.2

How Learn SQL in a Month of Lunches covers it

How deep it goes
Explains separate ownership, lookup behavior, examples, and write costs, but does not detail index internals or optimizer decisions.
Examples
Demonstrates library catalogs, shipment tracking numbers, and a ShipmentDate index supporting a grouped count.
What it assumes
Assumes familiarity with tables and queries while establishing the distinction between clustered and nonclustered indexes.
What you can do after
Apply it via SQL by creating focused indexes for columns used in selective queries.
How it connects
Connects nonclustered indexes with clustered indexes, primary keys, table scans, queries, and data modification operations.

Also explained in

Compare how 2 books explain nonclustered index →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn SQL in a Month of Lunches. The section links point to the parts of the book it draws on.