Search This Blog

Thursday, July 25, 2019

Indexing in Sql

An index is used to fast searching  record  with select Query  and where Clause  but its slow down with  input data Insert and  Update and deletes

An index can be used to efficiently find all rows matching some column in your query and then walk through only that subset of the table to find exact matches. If you don't have indexes on any column in the WHERE clause, the SQL server has to walk through the whole table and check every row to see if it matches, which may be a slow operation on big tables.

Clustered index creates a physical order of rows Basically Primary Key
Nonclustered index is also a binary tree but it doesn't create a physical order of rows.


Unique Indexe  Unique Index does not  allow any dublicate value to  be inserted

create table TestIndex
(MemberId int ,
 Name nvarchar(50),
  Age int )

create unique index U_MemberId
on  TestIndex(MemberId)


Implicit Indexes  Index are automatically created when  primary and  unique   key  are created


Avoid Indexing  
  • Index should not used small table
  • Index should not be used that column that contains heigh number of null value
  • Column that are frequently manipulated  should not be used

No comments :