Skip to content

Instantly share code, notes, and snippets.

@bertwagner
Last active February 20, 2017 17:10
Show Gist options
  • Save bertwagner/77e16de54a0706abe66b2c00dd9ae5d6 to your computer and use it in GitHub Desktop.
Save bertwagner/77e16de54a0706abe66b2c00dd9ae5d6 to your computer and use it in GitHub Desktop.
Adding a nonclustered index to our computed column
-- Add an index onto our computed column
CREATE CLUSTERED INDEX CL_CarModel ON dbo.Cars (CarModel)
-- Check the execution plans again
SELECT DISTINCT * FROM dbo.Cars WHERE JSON_VALUE(CarDetails, '$.model') = 'Golf'
SELECT DISTINCT * FROM dbo.Cars WHERE CarModel = 'Golf'
-- We now get index seeks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment