Database storage and query optimization principle

Query Optimization

1, the storage engine choices: If the data tables require a transaction, you should consider using InnoDB, because it is in full compliance with the ACID properties.
If no transaction processing, using the default MyISAM storage engine is wise to
2 points table and warehouses, master and slave.
3, query optimization, to try to avoid full table scans, should first consider the establishment by the column involved in where and order index
4, should be avoided for null fields to determine the value in the where clause, will cause the engine to give up using the index and a full table scan
5, should be avoided in the where clause! = or <> operator, otherwise the engine to give up using the index and a full table scan
6, should be avoided or used in the where clause to join condition, if a field has an index, a field is not indexed, will cause the engine to give up using the index and full table scan
7, Update statements, if only to change the 2 fields, do not Update all fields, otherwise called frequently cause significant the performance of consumption and bring a lot of log
8, for more than the amount of data Da (where hundreds even big) table JOIN, first page again JOIN, or logical reading will be high, poor performance.

Storage principle

Storage process is a programmable function that created and saved in the database. It may have some special SQL statements and control structures. When it is desired to perform the same function in different applications or internet, or a package with a particular function, the storage process is very useful. Database stored procedure can be seen as an object-oriented programming in the simulation method. It allows controlled access to data.
Stored procedure typically has the following advantages:
1, a stored procedure can achieve faster execution speed
2, a storage component is programmed to allow standard procedure.
3, the storage process can be prepared by the process control statements, a lot of flexibility, and can perform complex judgment operation more complex.
4, storage process may be used as a security mechanism to take advantage of.
5, stored procedures can reduce network traffic

Guess you like

Origin www.cnblogs.com/xiongying4/p/12507951.html