[MySQL]MySQL 今日點閱數效能問題

看板Database作者 (ChaN)時間14年前 (2011/05/26 17:26), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
因為客戶想要抓出 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

05/26 19:25, , 1F
先用 explain 看看吧....
05/26 19:25, 1F

06/03 15:48, , 2F
從datetime去切partition table
06/03 15:48, 2F
文章代碼(AID): #1DtXpBLV (Database)