Single n Double Index in field Table MySQL
Scenario is U have a lot of table that has big record….
When u want to looking for one record at that table…the query take time more slowly cause that query must be scanning all of the record at the table.
One of the trick to make query more fastly is make index at field that become key of searching.
For example : We have table with structure below :
+————————+
| StudentTable
+————————+
| StudentID (*)
| StudentName
| Birthday
| Telp
| ClassID
+————————+
- The key is StudentID (*) SINGLE n DOUBLE INDEX (my version) If the query is : SELECT StudentName, Birthday, Telp FROM StudentTable WHERE StudentID = "001" So… we can make one index that only contain field Student at that index. Syntax to create index at MySQL is : CREATE INDEX idStudentIndx ON StudenTable(StudentID); If the query is : SELECT StudentName, Birthday, Telp FROM StudentTable WHERE StudentID = "001" AND ClassID = "1A" The syntax to create index is : CREATE INDEX idStudentIndxDouble ON StudentTable(StudentID, ClassID); This is very helpfull to get result query more fastly… :) That’s has been prove it
