When you use the groupby group for query, the default group is sorted, which may reduce the speed. adding orderbynull after groupby can prevent sorting 1. when you query by group by, the default group is sorted, which may reduce the speed. adding order by null after group by can prevent sorting. 2. in some cases, you can use a connection to replace subqueries. Because join is used, MySQL does not need to create a temporary table in memory. Select * from dept, emp where dept. deptno = emp. deptno; [simple processing method] select * from dept left join emp on dept. deptno = emp. deptno; [left outer join, more OK!] How to choose mysql storage engine myisam storage: if the table does not have high transaction requirements and is mainly query and add, we will consider using the myisam storage engine ., for example, the posting table and reply table in bbs. INNODB storage: high transaction requirements and important data are stored. we recommend that you use INNODB, such as order tables and account tables. question: What is the difference between MyISAM and INNODB? 1. transaction Security innodb supports Things 2. fast query and acceleration conditions and query of MyISAM 3. support Full-text index myisam4. lock mechanism 5. the foreign key MyISAM does not support foreign keys. INNODB supports foreign keys. (in PHP development, foreign keys are usually not set, and data consistency is usually ensured in the program) Memory storage. for example, if data changes frequently and does not need to be written into the database, memory is frequently queried and modified. u if the storage engine of your database is myisam, remember to perform fragment on a regular basis.
Example:
create table test100(id int unsigned ,name varchar(32))engine=myisam; insert into test100 values(1,’aaaaa’); insert into test100 values(2,’bbbb’); insert into test100 values(3,’ccccc’);
We should define and sort out myisam
optimize table test100; mysql_query(“optimize tables "tbname”);