0

If I have a table and I create a index on Emp.Id, Emp.Name and Emp.Surname .(3 fields out of 10). Now if I query table with just Emp.Id will it fetch query based upon indexing (fast) or normal?

2 Answers2

1

Think of a telephone book.

It's indexed on last_name first, then first_name.

Does this help you look up a person by their last name only? Yes.

Does it help you look up a person by their first name only? No.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
0

If id is the first column in the index, then it can be used for a query filtering on the id.

This is a common practice when creating indexes, putting commonly used columns first, but then including others.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786