1
什麼是我的方案是最好的事情Mysql的大表,datetime列
我有一個表有近2000萬的記錄,這基本上存儲哪些用戶在該網站
id
都做 - >主INT 11自動遞增user_id
- >指數INT 11 NOT NULLcreate_date
- >(無指標還)日期 - 時間不是null- 它有其他列,但似乎不相干的他們在這裏命名
我知道我必須把一個索引上CREATE_DATE但我把一列索引或雙列,其中一個第一對雙指數(給定大量的記錄)?
通過的方式,我現在使用的查詢是這樣的:
select max(id) -- in here I'm selecting actions that users have done, after this date, since date is today
from table t
where
t.create_date >= '2014-12-29 00:00:00'
group by t.user_id