Last active
August 29, 2015 14:16
-
-
Save yoku0825/d26ce8f86f7c1722b3fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use DBI; | |
use Time::HiRes; | |
use Parallel::ForkManager; | |
my $dsn= "dbi:mysql:d1;mysql_socket=/tmp/mysql.sock"; | |
my $pm = Parallel::ForkManager->new(10); | |
while () | |
{ | |
my $pid = $pm->start and next; | |
my $conn= DBI->connect($dsn, "root", ""); | |
while () | |
{ | |
$conn->do("SELECT 1 FROM t1 WHERE val = ? OR val = ?", undef, Time::HiRes::time(), $pid); | |
} | |
$pm->finish; | |
} | |
exit 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> SET GLOBAL query_cache_type= 1; | |
Query OK, 0 rows affected (0.00 sec) | |
### run qcache.pl ### | |
mysql> show processlist; | |
+-------+------+-----------+------+---------+------+------------------------------+--------------------------------------------------------------+ | |
| Id | User | Host | db | Command | Time | State | Info | | |
+-------+------+-----------+------+---------+------+------------------------------+--------------------------------------------------------------+ | |
| 54679 | root | localhost | d1 | Query | 0 | starting | show processlist | | |
| 54690 | root | localhost | d1 | Query | 0 | Waiting for query cache lock | SELECT 1 FROM t1 WHERE val = '1425864656.15922' OR val = '0' | | |
| 54691 | root | localhost | d1 | Query | 0 | Waiting for query cache lock | SELECT 1 FROM t1 WHERE val = '1425864656.16056' OR val = '0' | | |
| 54692 | root | localhost | d1 | Query | 0 | Writing to net | SELECT 1 FROM t1 WHERE val = '1425864656.16157' OR val = '0' | | |
| 54693 | root | localhost | d1 | Query | 0 | Waiting for query cache lock | SELECT 1 FROM t1 WHERE val = '1425864656.16253' OR val = '0' | | |
| 54694 | root | localhost | d1 | Query | 0 | freeing items | SELECT 1 FROM t1 WHERE val = '1425864656.16162' OR val = '0' | | |
| 54695 | root | localhost | d1 | Query | 0 | Waiting for query cache lock | SELECT 1 FROM t1 WHERE val = '1425864656.1633' OR val = '0' | | |
| 54696 | root | localhost | d1 | Sleep | 0 | | NULL | | |
| 54697 | root | localhost | d1 | Query | 0 | Writing to net | SELECT 1 FROM t1 WHERE val = '1425864656.16509' OR val = '0' | | |
| 54698 | root | localhost | d1 | Query | 0 | Writing to net | SELECT 1 FROM t1 WHERE val = '1425864656.16422' OR val = '0' | | |
| 54699 | root | localhost | d1 | Query | 0 | Waiting for query cache lock | SELECT 1 FROM t1 WHERE val = '1425864656.16234' OR val = '0' | | |
+-------+------+-----------+------+---------+------+------------------------------+--------------------------------------------------------------+ | |
11 rows in set (0.00 sec) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> show create table t1\G | |
*************************** 1. row *************************** | |
Table: t1 | |
Create Table: CREATE TABLE `t1` ( | |
`num` bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |
`val` varchar(32) DEFAULT NULL, | |
UNIQUE KEY `num` (`num`) | |
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 | |
1 row in set (0.02 sec) | |
mysql> | |
mysql> SELECT * FROM t1; | |
+-----+------+ | |
| num | val | | |
+-----+------+ | |
| 1 | one | | |
| 2 | two | | |
+-----+------+ | |
2 rows in set (0.00 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment