3、生成 pm_indexs 表数据,增加一个字段 pmidold,升级后删除此字段
- INSERT INTO `pre_ucenter_pm_indexes` (plid, pmidold) SELECT l.plid, p.pmid FROM `pre_ucenter_pms` p LEFT JOIN
`pre_ucenter_pm_lists` l ON CONCAT(LEAST(p.msgfromid, p.msgtoid), '_', GREATEST(p.msgfromid, p.msgtoid)) = l.min_max WHERE p.related = 1;
4,插入短信分表数据
- INSERT INTO `pre_ucenter_pm_messages_0` (pmid, plid, authorid, message, delstatus, dateline)
SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message),
CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus,
IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `pre_ucenter_pm_indexes` i LEFT JOIN
`pre_ucenter_pms` p ON i.pmidold = p.pmid LEFT JOIN `pre_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 0;- INSERT INTO `pre_ucenter_pm_messages_1` (pmid, plid, authorid, message, delstatus, dateline)
SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message),
CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus,
IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `pre_ucenter_pm_indexes` i LEFT JOIN
`pre_ucenter_pms` p ON i.pmidold = p.pmid LEFT JOIN `pre_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 110 = 1;- INSERT INTO `pre_ucenter_pm_messages_2` (pmid, plid, authorid, message, delstatus, dateline)
SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message),
CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus,
IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `pre_ucenter_pm_indexes` i LEFT JOIN
`pre_ucenter_pms` p ON i.pmidold = p.pmid LEFT JOIN `pre_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 2;- INSERT INTO `pre_ucenter_pm_messages_3` (pmid, plid, authorid, message, delstatus, dateline)
SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message)
, CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus,- IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `pre_ucenter_pm_indexes` i LEFT JOIN
- `pre_ucenter_pms` p ON i.pmidold = p.pmid LEFT JOIN `pre_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 3;
- INSERT INTO `pre_ucenter_pm_messages_4` (pmid, plid, authorid, message, delstatus, dateline)
- SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message),
- CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus,
- IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `pre_ucenter_pm_indexes` i LEFT JOIN
- `pre_ucenter_pms` p ON i.pmidold = p.pmid LEFT JOIN `pre_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 4;
- INSERT INTO `pre_ucenter_pm_messages_5` (pmid, plid, authorid, message, delstatus, dateline)
- SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message),
- CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus,
- IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `pre_ucenter_pm_indexes` i LEFT JOIN
- `pre_ucenter_pms` p ON i.pmidold = p.pmid LEFT JOIN `pre_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 5;
- INSERT INTO `pre_ucenter_pm_messages_6` (pmid, plid, authorid, message, delstatus, dateline)
- SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message),
- CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus,
- IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `pre_ucenter_pm_indexes` i LEFT JOIN
- `pre_ucenter_pms` p ON i.pmidold = p.pmid LEFT JOIN `pre_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 6;
- INSERT INTO `pre_ucenter_pm_messages_7` (pmid, plid, authorid, message, delstatus, dateline)
- SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message),
- CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus,
- IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `pre_ucenter_pm_indexes` i LEFT JOIN
- `pre_ucenter_pms` p ON i.pmidold = p.pmid LEFT JOIN `pre_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 7;
- INSERT INTO `pre_ucenter_pm_messages_8` (pmid, plid, authorid, message, delstatus, dateline)
- SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message),
- CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus,
- IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `pre_ucenter_pm_indexes` i LEFT JOIN
- `pre_ucenter_pms` p ON i.pmidold = p.pmid LEFT JOIN `pre_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 8;
- INSERT INTO `pre_ucenter_pm_messages_9` (pmid, plid, authorid, message, delstatus, dateline)
- SELECT i.pmid, i.plid, p.msgfromid, IF(LENGTH(p.subject) > 0 AND STRCMP(p.subject, p.message),
- CONCAT(p.subject, '\r\n', p.message), p.message), IF(l.authorid = p.msgfromid, p.delstatus,
- IF(p.delstatus > 0, 3-p.delstatus, 0)), p.dateline FROM `pre_ucenter_pm_indexes` i LEFT JOIN
- `pre_ucenter_pms` p ON i.pmidold = p.pmid LEFT JOIN `pre_ucenter_pm_lists` l ON i.plid = l.plid WHERE i.plid % 10 = 9;