我有這樣的聊天表:指數聊天MySQL表
CREATE TABLE IF NOT EXISTS `support_chat` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`from` varchar(255) NOT NULL DEFAULT '',
`to` varchar(255) NOT NULL DEFAULT '',
`message` text NOT NULL,
`sent` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`seen` varchar(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `from` (`from`),
KEY `to` (`to`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;
基本上我需要做一個選擇所有的時間(每個用戶3秒),以檢查新郵件:
select id, `from`, message, sent from support_chat where `to` = ? and seen = 0
我有5個百萬行,通常同時在線100個用戶。我能改變一些東西來使這張桌子更快嗎?關鍵和關鍵是一個很好的選擇?
看來你有2個賬戶。請閱讀如何合併它們:[我意外創建了兩個帳戶;我如何合併它們?](http://dba.stackexchange.com/help/merging-accounts) –