Simply put, the database index is the data structure of the database! In addition, the data structure stores all the values of a column in a table, which means that the index is created based on a column in the data table. To sum up, an index consists of a column of data in a table, which is stored in a data structure.
2. The function of the index. For example, suppose there is a data table Emplyee, which has three columns:
There are tens of thousands of records in the table. Now you need to execute the following query statement to find out the details of all employees named "Jesus"
3. If there is no database index function, the database system will traverse the whole table line by line to check whether the Employee_Name field of each line is equal to "Jesus". Because we want to find all employees with the name "Jesus", when we find a record with the name "Jesus", we can't stop looking because there may be other employees with the name "Jesus". This means that for tens of thousands of records in the table, every record in the database should be checked. This is the so-called "full table scan" (? Full table scanning)
4. The biggest function of database index is to speed up the query, which can fundamentally reduce the number of records/rows to be scanned.
5. How to create a database index? You can create an index based on two columns of the Employee table:
An index is a structure that sorts the values of one or more columns in a database table. Using indexes can quickly access specific information in database tables. If you want to find a specific employee by last name, the index can help you get information faster than all the rows in the search table.
2. One of the main purposes of indexing is to speed up the method of retrieving the data in the table, that is, to help information searchers find the auxiliary data structure of the record ID that meets the restrictive conditions as soon as possible.
3. An index is a structure that sorts the values of one or more columns in a database table (for example, the name column in the employee table).
4. For example, such a query: select * from table 1, where ID = 10000. If there is no index, you must traverse the whole table until you find a row with an ID equal to 10000; Once you have an index (which must be built on the ID column), you can look it up in the index. Because the index is optimized by some algorithm, the number of searches is much less. As you can see, the index is used to locate.
5. From the point of view of data search, an index is another kind of file/record, which contains various records that can represent related data records. Each index has a corresponding search code, and any subset of character segments can form a search code. In this way, the index is equivalent to the collection of all data directory items, which can provide various effective support for locating all data directory items with a given search code value.
References:
Database Index-Baidu Encyclopedia