database - How clustered and Non clustered index makes search faster? -


clustered indexes physically order data on disk.

say have table employee , columd employee_id. store values 9, 6, 10, 4 under employee_id. clustered index on employee_id. values on disk stored in sorted fashion i.e 4, 6, 9, 10. if search on employee_id id 9, database can use search algorithm binary search or other quick spot record id 9. possible not fine record in 1 operation binary serach. is correct?

non clustered index non-clustered index has duplicate of data indexed columns kept ordered pointers actual data rows (pointers clustered index if there one). if take same example above. in case database create separate object store data along memory location.something this

9 -- phyical location

6 -- phyical location

10 -- phyical location

4 -- phyical location

so first need search 10 in newly created object , memory location. go orginal memory location. so how come makes search faster ?

also per understanding, index should created on column involved under clause not under select clause . right?

consider larger data set - not 4 values, million. querying via index may indeed have small overhead of having perform read table once correct physical location found, large data sets it's negligible when consider how faster searching index compared performing full scan on unsorted table.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -