看板 Database 關於我們 聯絡資訊
因為客戶想要抓出 blog 今天的點閱數 所以當初另外開了一個 blog_hits 紀錄 資料庫結構如下 bh_id int unsigned pk bh_date datetime bh_ip varchar(20) bid int unsigned (blog 連結用的 fk) 撈出今日點閱的語法如下 (SELECT COUNT(bh_id) FROM blog_hits WHERE blog.bid = blog_hits.bid AND DATEDIFF(blog_hites.bh_date, CURDATE()) = 0) 目前 total 資料筆數已達 4000 多萬,所以撈取這項內容的時後會有點卡卡的 該做索引的都有做索引 請問有辦法改善 query 效能嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.36.31.82
KC73:先用 explain 看看吧.... 05/26 19:25
iamnotfat:從datetime去切partition table 06/03 15:48