MySQL Optimization method:
- Use index:
There is no difference between indexed and indexed advantages:
When a table has a large number of records, to query the table, if the index is not used, the search information method is a full table search, is to take all records one by one out, and the query criteria for one by one comparison, and then return to meet the criteria of the record, which will consume a lot of database system time and cause a lot of disk I/O operations If an index is established for some fields in the table, and then the index values matching the query criteria are found in the index, the corresponding records in the table are found quickly by ROWID (equivalent page numbers) saved in the index.
Disadvantages:
When the data in the table is added, deleted and modified, the index is also maintained dynamically, reducing the maintenance speed of the data.
- To refine the query statement:
Query, you can not * do not have *, as far as possible to write the full field name;
- Transaction:
Its purpose is either that each statement in the statement block succeeds or fails. In other words, the consistency and integrity of the data in the database can be maintained. Things begin with the BEGIN keyword, and the commit keyword ends. When a SQL operation fails, the rollback command can restore the database to the state it was in before begin.
- Use connection (join) instead of subquery (sub-queries)
Select the most applicable field properties:
- Table optimization:
The table field is not NULL as much as possible;
Table queries with fixed field lengths are faster.
MySQL Optimization method