????????????SQL???????????100??
???????????? ???????[ 2014/9/30 11:09:04 ] ????????????? SQL ???????
??????????????
????????mysql???????????????????DBA????????????????IO?????IO???????? ????????7s?????
????SQL??????£?
????SELECT DISTINCT g.*?? cp.name AS cp_name?? c.name AS category_name?? t.name AS type_name FROMgm_game g LEFT JOIN gm_cp cp ON cp.id = g.cp_id AND cp.deleted = 0 LEFT JOIN gm_category c ON c.id = g.category_id AND c.deleted = 0 LEFT JOIN gm_type t ON t.id = g.type_id AND t.deleted = 0 WHERE g.deleted = 0 ORDER BY g.modify_time DESC LIMIT 20 ;
???????????????
???????explain????м??????????£?
????????sql???????????????????????
????????????????(?????????????????g.* )?????????????order by???????????????20???????
????DBA?????IO????????sql????????????????????????????£???????????????????????IO?????
???????????????
??????????????·????sql????????????????????????????????
?????????????????????????????????????g.id????
????SELECT DISTINCT g.id FROM gm_game g LEFT JOIN gm_cp cp ON cp.id = g.cp_id AND cp.deleted = 0 LEFT JOIN gm_category c ON c.id = g.category_id AND c.deleted = 0 LEFT JOIN gm_type t ON t.id = g.type_id AND t.deleted = 0 WHERE g.deleted = 0 ORDER BY g.modify_time DESC LIMIT 20 ;
????????????????????????????????????????sql???????in???????????????sql
????SELECT DISTINCT g.*?? cp.name AS cp_name??c.name AS category_name??t.name AS type_name FROMgm_game g LEFT JOIN gm_cp cp ON cp.id = g.cp_id AND cp.deleted = 0 LEFT JOIN gm_category c ON c.id = g.category_id AND c.deleted = 0 LEFT JOIN gm_type t ON t.id = g.type_id AND t.deleted = 0 WHERE g.deleted = 0 and g.id in(…………………) ORDER BY g.modify_time DESC ;
?????????Ч????
??????SATA????????????????????50s???????????0.3s???????0.1s????????????????????100???????IO?????????1%
??????SSD????????????????????7s???????????0.3s???????0.1s????????????????????10???????IO?????????1%
?????????????????????io???????????SSD????????SATA?????????????????????????SSD??SATA??????в??
???????????????
????MySQL?????SQL?????????????????????????£???????????ζ?????????
?????????洢
????MySQL???????“????????”??“?????????”?????????????????MySQL??MEMORY?洢???棬????????????MySQL??MyISAM?洢???棻
???????????£?MySQL?????????????????????????????????????????MySQL?????????????????????????
????Linux????????/tmp????/tmp??С????????????
????????????????
????1??ORDER BY????GROUP BY?????? ???磺ORDERY BY price GROUP BY name??
????2????JOIN????У?ORDER BY????GROUP BY????????????????? ???磺SELECT * from TableA?? TableB ORDER BY TableA.price GROUP by TableB.name
????3??ORDER BY???????DISTINCT????? ORDERY BY DISTINCT(price)
????4??SELECT??????????SQL_SMALL_RESULT????? SQL_SMALL_RESULT??????????MySQL????????С??????????????????????????????????? SQL_SMALL_RESULT?????GROUP BY??DISTINCT??DISTINCTROW?????? ???????£???????б?????????????MySQL??????????ɡ?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11