Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MySQL Order ByË÷ÒýÓÅ»¯

ÔÚһЩÇé¿öÏ£¬MySQL¿ÉÒÔÖ±½ÓʹÓÃË÷ÒýÀ´Âú×ãÒ»¸ö ORDER BY »ò GROUP BY ×Ó¾ä¶øÎÞÐè×ö¶îÍâµÄÅÅÐò¡£¾¡¹Ü ORDER BY ²»ÊǺÍË÷ÒýµÄ˳Ðò׼ȷƥÅ䣬Ë÷Òý»¹ÊÇ¿ÉÒÔ±»Óõ½£¬Ö»Òª²»ÓõÄË÷Òý²¿·ÖºÍËùÓеĶîÍâµÄ ORDER BY ×Ö¶ÎÔÚ WHERE ×Ó¾äÖж¼±»°üÀ¨ÁË¡£ ¡¡¡¡Ê¹ÓÃË÷ÒýµÄMySQL Order By ¡¡¡¡ÏÂÁеļ¸¸ö²éѯ¶¼»áʹÓÃË÷ÒýÀ´½â¾ö ORDER BY »ò GROUP BY ²¿·Ö£º SELECT * from t1 ORDER BY key_part1,key_part2,... ; SELECT * from t1 WHERE key_part1=constant ORDER BY key_part2; SELECT * from t1 WHERE key_part1=constant GROUP BY key_part2; SELECT * from t1 ORDER BY key_part1 DESC, key_part2 DESC; SELECT * from t1 WHERE key_part1=1 ORDER BY key_part1 DESC, key_part2 DESC; ¡¡¡¡²»Ê¹ÓÃË÷ÒýµÄMySQL Order By ¡¡¡¡ÔÚÁíһЩÇé¿öÏ£¬MySQLÎÞ·¨Ê¹ÓÃË÷ÒýÀ´Âú×ã ORDER BY£¬¾¡¹ÜËü»áʹÓÃË÷ÒýÀ´ÕÒµ½¼Ç¼À´Æ¥Åä WHERE ×Ӿ䡣ÕâЩÇé¿öÈçÏ£º ¡¡¡¡* ¶Ô²»Í¬µÄË÷Òý¼ü×ö ORDER BY £º SELECT * from t1 ORDER BY key1, key2; ¡¡¡¡* ÔÚ·ÇÁ¬ÐøµÄË÷Òý¼ü²¿·ÖÉÏ×ö ORDER BY£º SELECT * from t1 WHERE key2=constant ORDER BY key_part2; ¡¡¡¡* ͬʱʹÓÃÁË ASC ºÍ DESC£º SELECT * from t1 ORDER BY key_part1 DESC, key_part2 ASC; * ÓÃÓÚËÑË÷¼Ç¼µÄË÷Òý¼üºÍ×ö ORDER BY µÄ²»ÊÇͬһ¸ö£º SELECT * from t1 WHERE key2=constant ORDER BY key1; ¡¡¡¡* Óкܶà±íÒ»Æð×öÁ¬½Ó£¬¶øÇÒ¶ÁÈ¡µÄ¼Ç¼ÖÐÔÚ ORDER BY ÖеÄ×ֶζ¼²»È«ÊÇÀ´×ÔµÚÒ»¸ö·Ç³£ÊýµÄ±íÖУ¨Ò²¾ÍÊÇ˵£¬ÔÚ EXPLAIN ·ÖÎöµÄ½á¹ûÖеĵÚÒ»¸ö±íµÄÁ¬½ÓÀàÐͲ»ÊÇ const£©¡£ * ʹÓÃÁ˲»Í¬µÄ ORDER BY ºÍ GROUP BY ±í´ïʽ¡£ ¡¡¡¡* ±íË÷ÒýÖеļǼ²»ÊÇ°´Ðò´æ´¢¡£ÀýÈ磬HASH ºÍ HEAP ±í¾ÍÊÇÕâÑù¡£ ¡¡¡¡Í¨¹ýÖ´ÐÐ EXPLAIN SELECT ... ORDER BY£¬¾ÍÖªµÀMySQLÊÇ·ñÔÚ²éѯÖÐʹÓÃÁËË÷Òý¡£Èç¹û Extra ×ֶεÄÖµÊÇ Using filesort£¬Ôò˵Ã÷MySQLÎÞ·¨Ê¹ÓÃË÷Òý¡£ÏêÇéÇë¿´"7.2.1 EXPLAIN Syntax (Get Information About a SELECT)"¡£µ±±ØÐë¶Ô½á¹û½øÐÐÅÅÐòʱ£¬MySQL 4.1ÒÔÇ° ËüʹÓÃÁËÒÔÏ filesort Ëã·¨£º ¡¡¡¡1. ¸ù¾ÝË÷Òý¼ü¶ÁÈ¡¼Ç¼£¬»òÕßɨÃèÊý¾Ý±í¡£ÄÇЩÎÞ·¨Æ¥Åä WHERE ·Ö¾äµÄ¼Ç¼¶¼»á±»ÂÔ¹ý¡£ ¡¡¡¡2. ÔÚ»º³åÖÐÿÌõ¼Ç¼¶¼ÓÃÒ»¸ö‘¶Ô’´æ´¢ÁË2¸öÖµ£¨Ë÷Òý¼ü¼°¼Ç¼ָÕ룩¡£»º³åµÄ´óСÒÀ¾Ýϵͳ±äÁ¿ sort_buffer_size µÄÖµ¶ø¶¨¡£ ¡¡¡¡3. µ±»º³åÂýÁËʱ£¬¾ÍÔËÐÐ qsort£¨¿ìËÙÅÅÐò£©²¢½«½á¹û´æ´¢ÔÚÁÙʱÎļþÖС£½«´æ´¢µÄ¿éÖ¸Õë±£´æÆðÀ´£¨Èç¹ûËùÓ


Ïà¹ØÎĵµ£º

Windows Ï Apache Mysql PHP µÄ°²×°

Ò»  Apache µÄ°²×°
 1  Apache µÄ°²×°
2 ͬÒâЭÒé
3 ½Ó×Å "Next "
4  Ìîд ÓòÃû(network domain) ·þÎñÆ÷µÄÃû³Æ (Server Name) ¹ÜÀíÕßÓÊÏä(Administrator's Email)
5 °²×°ÀàÐÍ
6 Ñ¡Ôñ°²×°Â·¾¶
7 µã»÷“install ” ¼ÌÐø
8 ¿ªÊ¼°²×°
9  °²×°½áÊø
¶þ   MySqlµÄ°²×° ......

apacheµÄ¾²Ì¬/¶¯Ì¬±àÒëÔÚapache+php+mysqlµÄÓ¦ÓÃ

apacheµÄ¾²Ì¬/¶¯Ì¬±àÒëÔÚapache+php+mysqlµÄÓ¦ÓÃ
ÎÒÏë´ó¼ÒÓв»ÉÙ¶¼³É¹¦ÊµÏÖapache+php+mysql£¬ÍøÉϵÄÎÄÕÂÒ²Óв»ÉÙ£¬µ«ÎÒ·¢ÏÖ²»ÉÙÎÄÕ¶¼Êdz­À´³­È¥£¬²¢ÇÒ
ûÓÐ˵Ã÷°×±àÒëµÄ·½Ê½£¬ÓеÄË÷ÐÔapache1.3µÄ±àÒë·½·¨Ô­·â²»¶¯µÄ°á¹ýÀ´Ì×ÔÚapache2.0£¬ÏÔÈ»Îóµ¼Ò»Ð©²ËÄñ £¡
ÎÒ½ñÌì¾ÍÒÔapache+mysql+php˵һϾ²Ì¬±àÒëºÍDSO¶¯Ì¬±à ......

¹ØÓÚMySQLµÄÂýÈÕÖ¾·ÖÎö¹¤¾ß

½ñÌìÎÒÃÇ¿´¿´¹ØÓÚMySQLÂýÈÕÖ¾µÄÔĶÁ¡£
ÎÒÃÇÖªµÀ£¬Èç¹ûÎÒÃǵÄÓï¾ä²»¹»ÓÅ»¯£¬ÄÇôÊ×ÏÈMySQLµÄÂýÈÕÖ¾ÊǽøÒ»²½ÓÅ»¯µÄÀëÏßÖ¤¾Ý£¬ËäÈ»ÀïÃæÓкÃ
¶à“αÂýÓï¾ä”£¡
ÏȲ»ËµÔõôÓÅ»¯£¬Èç¹ûÄãµÄÈÕÖ¾ÓÐÒ»ÌõÓï¾ä¶ÄסÁË£¬ÄÇô»áÓв»¼ÆÆäÊýµÄÂýÓï¾äÌî³äµ½MySQLµÄÂúÈÕÖ¾ÀïÃæ¡£ÄÇôÊ×ÏÈÌáÁ¶³öÕâЩÓï
¾ä¾Í·Ç³£Í·ÌÛ¡£
½ñÌìÖ÷Òª½ ......

mysqlµÄcardinalityÔÚmyisamºÍinnodbÖеIJ»Í¬

Ïêϸ½âÊͺÍÀý×Ó¼ûÏÂÁÐÎÄÕ£º
http://www.mysqlperformanceblog.com/2008/09/03/analyze-myisam-vs-innodb/
http://www.penglixun.com/work/database/mysql_show_index_cardinality.html
£¨1£©cardinalityÓ°Ïìmysql optimizer¶ÔË÷ÒýµÄÑ¡È¡
£¨2£©¿ÉÒÔͨ¹ýshow index from table_nameÀ´²é¿´±íµÄË÷ÒýºÍcardinality
£¨3£©in ......

MySQLµÄ¡°SET NAMES x¡±×Ö·û¼¯ÎÊÌâ·ÖÎö

MySQLµÄ×Ö·û¼¯ÎÊÌâ¡£WindowsÏ¿Éͨ¹ýÐÞ¸Ämy.iniÄÚµÄ
CODE:
# CLIENT SECTION
[mysql]
default-character-set=utf8
#
SERVER SECTION
[mysqld]
default-character-set=utf8
Õâ
Á½¸ö×Ö¶ÎÀ´¸ü¸ÄÊý¾Ý¿â
µÄ
ĬÈÏ×Ö·û¼¯¡£µÚÒ»¸öÊÇ¿Í»§¶ËĬÈϵÄ×Ö·û¼¯£¬µÚ¶þ¸öÊÇ·þÎñÆ÷¶ËĬÈϵÄ×Ö·û¼¯¡£¼ÙÉèÎÒÃÇ°ÑÁ½¸ö¶¼ÉèΪutf8£¬È»ºó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ