SlideShare ist ein Scribd-Unternehmen logo
1 von 15
DATABASE INDEX
Sql Server, Mysql, Oracle
Database Without Index
 Lets assume Sql Server, MySql and Oracle doesn’t
support Index.
 How to handle this siltation?
 Why Indexes has introduced in the database?
Benefit of In Built Index
 Data synchronization
 When data is inserted in the table, same data is also
inserted into the index.
 When data is deleted from the table same, data is also
deleted from the index.
 When data is updated in the table, same data is also
updated in the index.
How To Create Indexes?
CREATE TABLE tblEmployee(
ntEmployeeID BIGINT PRIMARY KEY,
vcEmpName VARCHAR(200),
dtDoj DATETIME,
btGender BIT,
vcSkill VARCHAR(2000),
moSalary MONEY,
ntHirarchyID BIGINT
)
Common Misconception
 Table design doesn’t decide index.
 It may help some extent .
 Primary key should be primary index (Clustered
index) of a table.
 All tables should have a clustered index on a
primary key column
Where To Start?
 OLAP (Online Analytical Processing)
 OLTP (Online Transaction Processing)
 What data is needed from a table?
 What queries are executing on a table?
How To Know What Queries Are Executing ?
 Find out all the in-lines queries.
 Find out all the queries from stored procedures
and database functions.
 Use DMVS or metadata tables to get queries.
Steps To Create Indexes
 Identify the application nature(OLAP OLTP)
 OLAP: Create index if necessary.
 OLTP: Create index if very necessary.
 OLAP + OLTP
 Sort the all queries on the base of frequency of
execution and query execution time.
Rule 1
 Create indexes on a table if the queries which fetch data
from a table have at least following clauses:
Clause Logical Processing Order
ON 1
WHERE 2
GROUP BY 3
HAVING 4
ORDER BY 5
DISTINCT 6
UNION NA
EXCEPT NA
INTERSECT NA
Rule 2
 Create index on the fields in which data are filtered only using
following operators in WHERE clause, ON clause and HAVING clause:
Operator Type
= Equality
< Range
> Range
<= Range
>= Range
IN Range
BETWEEN Range
LIKE Range
Rule 3
 Don't create indexes on the columns which are
expression in the query.
 We will discuss later how to create indexes of
such predicates.
Order of column name in an index
 Index 1:
CREATE INDEX NCI_a_b ON tblEmployee(a,b)
 Index 2:
CREATE INDEX NCI_b_a ON tblEmployee(b,a)
 Here index NCI_a_b and NCI_b_a are two totally different
indexes.
Rule 4
 Try to avoid creating single column indexes if
multi column index is possible.
 If we are creating multi column index, keep
columns order according to logical order of
processing of different clauses.
Rule 5
 Keep the all columns with equality operator first.
 One columns with range operators is allowed .
 If columns with range operator has not included
then only columns in GROUP BY Clause or ORDER
BY clause should be included.
Rule 6
 If there are two columns with equality operator
then column which has most number of distinct
values should be included first.

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Database index(sql server)
Database index(sql server)Database index(sql server)
Database index(sql server)
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMS
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
Binary search tree in data structures
Binary search tree in  data structuresBinary search tree in  data structures
Binary search tree in data structures
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 
NOSQL Databases types and Uses
NOSQL Databases types and UsesNOSQL Databases types and Uses
NOSQL Databases types and Uses
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Anomalies in database
Anomalies in databaseAnomalies in database
Anomalies in database
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
 
Data models
Data modelsData models
Data models
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Advanced sql
Advanced sqlAdvanced sql
Advanced sql
 
AVL Tree in Data Structure
AVL Tree in Data Structure AVL Tree in Data Structure
AVL Tree in Data Structure
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 

Andere mochten auch

Andere mochten auch (20)

12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 
CS 542 Database Index Structures
CS 542 Database Index StructuresCS 542 Database Index Structures
CS 542 Database Index Structures
 
Indexes
IndexesIndexes
Indexes
 
PostgreSQL: Advanced indexing
PostgreSQL: Advanced indexingPostgreSQL: Advanced indexing
PostgreSQL: Advanced indexing
 
Data indexing presentation
Data indexing presentationData indexing presentation
Data indexing presentation
 
Advanced Index, Partitioning and Compression Strategies for SQL Server
Advanced Index, Partitioning and Compression Strategies for SQL ServerAdvanced Index, Partitioning and Compression Strategies for SQL Server
Advanced Index, Partitioning and Compression Strategies for SQL Server
 
Sql index
Sql indexSql index
Sql index
 
Geek Sync | SQL Server Indexing Basics
Geek Sync | SQL Server Indexing BasicsGeek Sync | SQL Server Indexing Basics
Geek Sync | SQL Server Indexing Basics
 
Les11 Including Constraints
Les11 Including ConstraintsLes11 Including Constraints
Les11 Including Constraints
 
Indexing basics
Indexing basicsIndexing basics
Indexing basics
 
Advanced User Privileges
Advanced User PrivilegesAdvanced User Privileges
Advanced User Privileges
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
Less07 Users
Less07 UsersLess07 Users
Less07 Users
 
Writing optimal queries
Writing optimal queriesWriting optimal queries
Writing optimal queries
 
Postgre sql unleashed
Postgre sql unleashedPostgre sql unleashed
Postgre sql unleashed
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for files
 
Columnstore indexes in sql server 2014
Columnstore indexes in sql server 2014Columnstore indexes in sql server 2014
Columnstore indexes in sql server 2014
 
User, roles and privileges
User, roles and privilegesUser, roles and privileges
User, roles and privileges
 
Data Processing Inside PostgreSQL
Data Processing Inside PostgreSQLData Processing Inside PostgreSQL
Data Processing Inside PostgreSQL
 

Ähnlich wie Database index

Application sql issues_and_tuning
Application sql issues_and_tuningApplication sql issues_and_tuning
Application sql issues_and_tuningAnil Pandey
 
Database Application for La Salle
Database Application for La SalleDatabase Application for La Salle
Database Application for La SalleJimmy Chu
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsDave Stokes
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfDraguClaudiu
 
Query parameterization
Query parameterizationQuery parameterization
Query parameterizationRiteshkiit
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007paulguerin
 
05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptx05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptxMohamedNowfeek1
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic ConceptsTony Wong
 
02 database oprimization - improving sql performance - ent-db
02  database oprimization - improving sql performance - ent-db02  database oprimization - improving sql performance - ent-db
02 database oprimization - improving sql performance - ent-dbuncleRhyme
 
Sql server ___________session_17(indexes)
Sql server  ___________session_17(indexes)Sql server  ___________session_17(indexes)
Sql server ___________session_17(indexes)Ehtisham Ali
 
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
MySQL Indexing : Improving Query Performance Using Index (Covering Index)MySQL Indexing : Improving Query Performance Using Index (Covering Index)
MySQL Indexing : Improving Query Performance Using Index (Covering Index)Hemant Kumar Singh
 
Database Performance
Database PerformanceDatabase Performance
Database PerformanceBoris Hristov
 
Steps towards of sql server developer
Steps towards of sql server developerSteps towards of sql server developer
Steps towards of sql server developerAhsan Kabir
 
MySQL Indexing
MySQL IndexingMySQL Indexing
MySQL IndexingBADR
 
Ms sql server ii
Ms sql server  iiMs sql server  ii
Ms sql server iiIblesoft
 

Ähnlich wie Database index (20)

Application sql issues_and_tuning
Application sql issues_and_tuningApplication sql issues_and_tuning
Application sql issues_and_tuning
 
MSSQL_Book.pdf
MSSQL_Book.pdfMSSQL_Book.pdf
MSSQL_Book.pdf
 
Database Application for La Salle
Database Application for La SalleDatabase Application for La Salle
Database Application for La Salle
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query Optimizations
 
Module08
Module08Module08
Module08
 
Module08
Module08Module08
Module08
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
 
Query parameterization
Query parameterizationQuery parameterization
Query parameterization
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007
 
05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptx05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptx
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
 
Mysql Optimization
Mysql OptimizationMysql Optimization
Mysql Optimization
 
02 database oprimization - improving sql performance - ent-db
02  database oprimization - improving sql performance - ent-db02  database oprimization - improving sql performance - ent-db
02 database oprimization - improving sql performance - ent-db
 
Sql server ___________session_17(indexes)
Sql server  ___________session_17(indexes)Sql server  ___________session_17(indexes)
Sql server ___________session_17(indexes)
 
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
MySQL Indexing : Improving Query Performance Using Index (Covering Index)MySQL Indexing : Improving Query Performance Using Index (Covering Index)
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
 
Database Performance
Database PerformanceDatabase Performance
Database Performance
 
Steps towards of sql server developer
Steps towards of sql server developerSteps towards of sql server developer
Steps towards of sql server developer
 
MySQL Indexing
MySQL IndexingMySQL Indexing
MySQL Indexing
 
Ms sql server ii
Ms sql server  iiMs sql server  ii
Ms sql server ii
 
SQL Views
SQL ViewsSQL Views
SQL Views
 

Mehr von Riteshkiit

Backup and restore
Backup and restoreBackup and restore
Backup and restoreRiteshkiit
 
Sql server introduction fundamental
Sql server introduction fundamentalSql server introduction fundamental
Sql server introduction fundamentalRiteshkiit
 
Order by and join
Order by and joinOrder by and join
Order by and joinRiteshkiit
 
Sql server introduction
Sql server introductionSql server introduction
Sql server introductionRiteshkiit
 
Database design
Database designDatabase design
Database designRiteshkiit
 
Sql server JOIN
Sql server JOINSql server JOIN
Sql server JOINRiteshkiit
 
Sql query performance analysis
Sql query performance analysisSql query performance analysis
Sql query performance analysisRiteshkiit
 
Sql query performance analysis
Sql query performance analysisSql query performance analysis
Sql query performance analysisRiteshkiit
 

Mehr von Riteshkiit (14)

Backup and restore
Backup and restoreBackup and restore
Backup and restore
 
Sql server introduction fundamental
Sql server introduction fundamentalSql server introduction fundamental
Sql server introduction fundamental
 
Index_2
Index_2Index_2
Index_2
 
Order by and join
Order by and joinOrder by and join
Order by and join
 
Sql server introduction
Sql server introductionSql server introduction
Sql server introduction
 
Database design
Database designDatabase design
Database design
 
Statistics
StatisticsStatistics
Statistics
 
Index
IndexIndex
Index
 
Addhoc query
Addhoc queryAddhoc query
Addhoc query
 
Sql server JOIN
Sql server JOINSql server JOIN
Sql server JOIN
 
Sql server 2
Sql server 2Sql server 2
Sql server 2
 
Sql query performance analysis
Sql query performance analysisSql query performance analysis
Sql query performance analysis
 
Sql query performance analysis
Sql query performance analysisSql query performance analysis
Sql query performance analysis
 
Topics
TopicsTopics
Topics
 

Kürzlich hochgeladen

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 

Kürzlich hochgeladen (20)

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

Database index

  • 2. Database Without Index  Lets assume Sql Server, MySql and Oracle doesn’t support Index.  How to handle this siltation?  Why Indexes has introduced in the database?
  • 3. Benefit of In Built Index  Data synchronization  When data is inserted in the table, same data is also inserted into the index.  When data is deleted from the table same, data is also deleted from the index.  When data is updated in the table, same data is also updated in the index.
  • 4. How To Create Indexes? CREATE TABLE tblEmployee( ntEmployeeID BIGINT PRIMARY KEY, vcEmpName VARCHAR(200), dtDoj DATETIME, btGender BIT, vcSkill VARCHAR(2000), moSalary MONEY, ntHirarchyID BIGINT )
  • 5. Common Misconception  Table design doesn’t decide index.  It may help some extent .  Primary key should be primary index (Clustered index) of a table.  All tables should have a clustered index on a primary key column
  • 6. Where To Start?  OLAP (Online Analytical Processing)  OLTP (Online Transaction Processing)  What data is needed from a table?  What queries are executing on a table?
  • 7. How To Know What Queries Are Executing ?  Find out all the in-lines queries.  Find out all the queries from stored procedures and database functions.  Use DMVS or metadata tables to get queries.
  • 8. Steps To Create Indexes  Identify the application nature(OLAP OLTP)  OLAP: Create index if necessary.  OLTP: Create index if very necessary.  OLAP + OLTP  Sort the all queries on the base of frequency of execution and query execution time.
  • 9. Rule 1  Create indexes on a table if the queries which fetch data from a table have at least following clauses: Clause Logical Processing Order ON 1 WHERE 2 GROUP BY 3 HAVING 4 ORDER BY 5 DISTINCT 6 UNION NA EXCEPT NA INTERSECT NA
  • 10. Rule 2  Create index on the fields in which data are filtered only using following operators in WHERE clause, ON clause and HAVING clause: Operator Type = Equality < Range > Range <= Range >= Range IN Range BETWEEN Range LIKE Range
  • 11. Rule 3  Don't create indexes on the columns which are expression in the query.  We will discuss later how to create indexes of such predicates.
  • 12. Order of column name in an index  Index 1: CREATE INDEX NCI_a_b ON tblEmployee(a,b)  Index 2: CREATE INDEX NCI_b_a ON tblEmployee(b,a)  Here index NCI_a_b and NCI_b_a are two totally different indexes.
  • 13. Rule 4  Try to avoid creating single column indexes if multi column index is possible.  If we are creating multi column index, keep columns order according to logical order of processing of different clauses.
  • 14. Rule 5  Keep the all columns with equality operator first.  One columns with range operators is allowed .  If columns with range operator has not included then only columns in GROUP BY Clause or ORDER BY clause should be included.
  • 15. Rule 6  If there are two columns with equality operator then column which has most number of distinct values should be included first.