There is SQL- script, which generated the Nonclustered Index with Included Column:
CREATE TABLE users
(
id INT,
firstname VARCHAR(50),
surname VARCHAR(50)
);
CREATE CLUSTERED INDEX ix_users_id
ON users (id);
CREATE NONCLUSTERED INDEX ix_users_firstname
ON users (firstname)
include (surname);
SELECT firstname,
surname
FROM users
WHERE firstname = 'John';
If I correctly understood, most of the time, Engine of my SQL Server 2019 will seek Nonclustered Index for the above SELECT query, without touching the Clustered Index. Does that mean the value of surname
column is stored in Leaf Node of the Nonclustered Index? Also, that means the value of surname
is duplicated because it also stored in Clustered Index.
Am I right?