- 论坛徽章:
- 0
|
请问一下一张表3600万数据, 有索引的时候查询还需要15秒左右,正常么?
用explain看过执行计划, 的确有使用索引,
不知道有没有办法缩短查询时间?
使用的是5.1.23rc, 数据库引擎是MYISAM
硬件配置: 2 * INTEL 5030 CPU, 2G内存
mysql> DESC NPE_RECORD_2008081323;
+--------------------------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+----------------------+------+-----+---------+-------+
| DEVICE_IP | int(10) unsigned | YES | | NULL | |
| PROTOCOLIDENTIFIER | tinyint(3) unsigned | YES | | NULL | |
| APP_PROTOCOL | tinyint(3) unsigned | YES | | NULL | |
| SOURCEIPV4ADDRESS | int(10) unsigned | YES | MUL | NULL | |
| DESTINATIONIPV4ADDRESS | int(10) unsigned | YES | | NULL | |
| SOURCETRANSPORTPORT | smallint(5) unsigned | YES | | NULL | |
| DESTINATIONTRANSPORTPORT | smallint(5) unsigned | YES | | NULL | |
| NAT_SRC_IP | int(10) unsigned | YES | | NULL | |
| NAT_DST_IP | int(10) unsigned | YES | MUL | NULL | |
| NAT_SRC_PORT | smallint(5) unsigned | YES | | NULL | |
| NAT_DST_PORT | smallint(5) unsigned | YES | | NULL | |
| IN_OCTETS | int(10) unsigned | YES | | NULL | |
| OUT_OCTETS | int(10) unsigned | YES | | NULL | |
| FLOW_CREATE_TIME | int(10) unsigned | NO | | NULL | |
| FLOW_DIE_TIME | int(10) unsigned | NO | MUL | NULL | |
+--------------------------+----------------------+------+-----+---------+-------+
mysql> show index from NPE_RECORD_2008081323;+-----------------------+------------+--------------------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-----------------------+------------+--------------------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+
| NPE_RECORD_2008081323 | 1 | INDX_DIETIME | 1 | FLOW_DIE_TIME | A | 3575 | NULL | NULL | | BTREE | |
| NPE_RECORD_2008081323 | 1 | INDX_SOURCEIP | 1 | SOURCEIPV4ADDRESS | A | 10000 | NULL | NULL | YES | BTREE | |
| NPE_RECORD_2008081323 | 1 | INDX_DESTINATIONIP | 1 | NAT_DST_IP | A | 20000 | NULL | NULL | YES | BTREE | |
+-----------------------+------------+--------------------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+
3 rows in set (0.00 sec)
mysql> SELECT COUNT(1) FROM NPE_RECORD_2008081323 WHERE SOURCEIPV4ADDRESS=3232236637 AND FLOW_CREATE_TIME>1218639600 AND FLOW_DIE_TIME<1218643199;
+----------+
| COUNT(1) |
+----------+
| 3073 |
+----------+
1 row in set (14.05 sec)
[ 本帖最后由 yj1804 于 2008-8-14 15:15 编辑 ] |
|