2. 利用php根据搜索字段长度来区分搜索的表.
核心代码:
$type = ($_POST['type']); switch ($type) { case 'qq': if (strlen("$length") >= 5 && strlen("$length") <= 7) { $tables = 'qq_num7'; } elseif (strlen("$length") == 8) { $tables = 'qq_num8'; } elseif (strlen("$length") == 9) { $tables = 'qq_num9_'; } elseif (strlen("$length") == 10) { $tables = 'qq_num10'; } else { echo "It's null nab ;D"; exit(); }
最终处理完后, 文件大小变大一些(Myisam), 处理前为924,676,608 字节, 处理后为959,333,988 字节,速度后速度提升N倍! 8位一下及10位QQ查询速度在0.1s内, 9位QQ查询速度在2s内. (i7, hdd, 8g)
5位:
select QQNum,Nick,Age,QunNum from `qq_num7` where QQNum = '12345' limit 200页面运行时间: 0.065625905990601 秒
QQ号码 | QQ昵称 | 年龄 | QQ群号 | 群名字 | 群信息 |
12345 | 12345·深圳 | 11 | 32084455 | ||
12345 | 12345 | 11 | 42184150 | 斯坦索姆-《逆鳞》 | |
12345 | 12345 | 11 | 64591366 | 霏凡 | |
12345 | 12345 | 11 | 65264217 | 心情祁东 | 来到启东矿可能就是一种缘分我们可能来自不同的学校我们还有梦想吗 |
12345 | 12345 | 11 | 65264348 | 没事找事 |
9位:
select QQNum,Nick,Age,QunNum from `qq_num9_1` where QQNum = '123123123'
limit 200 union all select QQNum,Nick,Age,QunNum from `qq_num9_2` where
QQNum = '123123123' limit 200 union all select QQNum,Nick,Age,QunNum
from `qq_num9_3` where QQNum = '123123123' limit 200 union all select
QQNum,Nick,Age,QunNum from `qq_num9_4` where QQNum = '123123123' limit
200 union all select QQNum,Nick,Age,QunNum from `qq_num9_5` where QQNum =
'123123123' limit 200 union all select QQNum,Nick,Age,QunNum from
`qq_num9_6` where QQNum = '123123123' limit 200 union all select
QQNum,Nick,Age,QunNum from `qq_num9_7` where QQNum = '123123123' limit
200 union all select QQNum,Nick,Age,QunNum from `qq_num9_8` where QQNum =
'123123123' limit 200 union all select QQNum,Nick,Age,QunNum from
`qq_num9_9` where QQNum = '123123123' limit 200页面运行时间: 0.13813106536865 秒
QQ号码 | QQ昵称 | 年龄 | QQ群号 | 群名字 | 群信息 |
123123123 | 皮皮 | 30 | 40720626 | ONE | |
123123123 | 丫o℡莼粉Sè | 30 | 45441346 | ☆BABY々十二☆ | 不许骂人。。不许打架。。。不许泡妞。。。 |
123123123 | 丫o℡莼粉Sè | 30 | 84318726 | ~吹BB~ | 祢⒋我;⒈軰子啲樶噯ぅ゛.︵鮱婆硪愛tan///?? |
123123123 | 丫o℡莼粉Sè | 30 | 85265897 | 看群公告!好消息! | 免费拿話費兩百块!群里的朋友们用手机拨打1259064212参加侣友在线答题就可以了,我今 |