日期:2014-05-16  浏览次数:21031 次

线上MySQL 32G大小的表truncate所消耗的时间为2分钟,快还是慢?

执行结果:

access_token 32G

mysql>  truncate table xxx.access_token;         
Query OK, 0 rows affected (1 min 47.84 sec)  truncate一个32G的表需要近2分钟,这算快还是慢呢?


refresh_token 26G
mysql>  truncate table xxx.refresh_token;        
Query OK, 0 rows affected (1 min 7.18 sec)


remember_me_token 1.3G
mysql>  truncate table xxx.remember_me_token;    
Query OK, 0 rows affected (1.87 sec)



Check DB Server环境.

1 察看内存以及缓存

top - 07:55:56 up 256 days,  4:53,  3 users,  load average: 0.00, 0.09, 0.22
Tasks: 175 total,   1 running, 174 sleeping,   0 stopped,   0 zombie
Cpu0  :  2.2%us,  0.9%sy,  0.0%ni, 96.4%id,  0.4%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu1  :  2.4%us,  1.1%sy,  0.0%ni, 96.0%id,  0.4%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu2  :  2.3%us,  0.9%sy,  0.0%ni, 96.3%id,  0.4%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu3  :  2.2%us,  0.9%sy,  0.0%ni, 96.4%id,  0.4%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  32750360k total, 32472008k used,   278352k free,   271932k buffers
Swap:  4194296k total,   505844k used,  3688452k free,  3554324k cached


2 察看系统版本

[novamysqladminlt@nucltmapc04db01 ~]$ cat /etc/issue
Red Hat Enterprise Linux Server release 6.3 (Santiago)
Kernel \r on an \m


3 察看操作系统位数

[xxxxx@xxxxxx~]$ ldd /sbin/mii-tool
        linux-vdso.so.1 =>  (0x00007fff9b1ff000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x0000003ec2400000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003ec0c00000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000003ec0800000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003ec0400000)


4 察看磁盘

[xxx@xxx~]$ vmstat 1
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0 505928 274840 272104 3558732    0    0     3    58    0    0  2  1 96  0  0
 0  0 505928 274732 272104 3558772    0    0     0   112 1036 1438  1  1 98  0  0
 1  2 505928 274732 272104 3558812    0    0     0  1796  960 1276  1  2 96  2  0
 1  0 505928 269112 272104 3558836    0    0     0  5564 2005 1861 12  5 83  1  0
 0  0 505928 274484 272104 3558864    0    0     0   112 1568 1969 11  2 87  0  0
 0  0 505928 274484 272104 3558892    0    0     0   128  924 1221  1  2 97  0  0
 1