- When SELECT field, minimize the use of t * such wording, only to write the column name to be queried.;
- Multimeter alias multi-table queries, writing specifications, using the AS keyword;
- Multi-query conditions where, having mainly on keyword filtering the result of polymerization;
- Try right column index calculation operations, such as where sum (a + b)> 3;
- When specify your search with more than exist, less in, and and or;
Reference: SQL statement Daquan SQL performance optimization (constantly sum) - The difference between TRUNCATE and DELETE: TRUNCATE equivalent to empty the table can not be deleted; delete to delete some data to meet the conditions of the rollback before committing the transaction.
- Try using capital letters to write SQL, a database to improve recognition speed statement;
- ! From the viewpoint of performance improvement, = less, using> or <;
- Try not applicable NULL keywords empty judgment; nulls may not allow the design of a database or a default value instead of null values;
- Use deduplication rowid; deduplication via the ROWID;
DELETE FROM person t1
WHERE t1.rowid > (SELECT MIN(t2.rowid)
FROM employees t2
WHERE t1.employee_id = t2.employee_id --按照想要唯一保留的字段进行匹配
);
11. To use the index columns used in the query.