我如何清理 mysql 上的临时表

2023-12-23

我们在程序中创建临时表,并且我们不使用 mysql 的持久连接。 mysql重启后,有很多临时表慢慢增加,然后innodb_buffer_pool_size正在整理。

应用程序正在该服务器上运行;

CPU E3-1245 v5 @ 3.50GHz - 8 核 16GB 内存

该图显示了 tmp 表的增长情况:

My.cnf:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

skip_name_resolve

join_buffer_size = 4M
sort_buffer_size = 1M
read_rnd_buffer_size = 1M

# MyISAM #
key_buffer_size                 = 1G
# SAFETY #
max_allowed_packet              = 1G
# CACHES AND LIMITS #
tmp_table_size                 = 16M
max_heap_table_size            = 16M
query_cache_type               = 1
query_cache_size               = 1M
query_cache_limit              = 1M
max_connections                = 400
thread_cache_size              = 100
open_files_limit               = 65535
table_definition_cache         = 4096
table_open_cache               = 4096

# INNODB #
innodb_flush_method            = O_DIRECT
innodb_log_files_in_group      = 2
innodb_log_file_size           = 512M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table          = 1
innodb_buffer_pool_size        = 10G
innodb_buffer_pool_instances=8
thread_pool_size=36

InnoDB状态:

=====================================
2017-05-31 15:52:22 7fbabc7be700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 59 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 9224 srv_active, 0 srv_shutdown, 9 srv_idle
srv_master_thread log flush and writes: 9233
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 134197
OS WAIT ARRAY INFO: signal count 204301
Mutex spin waits 1288150, rounds 3214506, OS waits 81031
RW-shared spins 54484, rounds 1299121, OS waits 39945
RW-excl spins 11585, rounds 514527, OS waits 12875
Spin rounds per wait: 2.50 mutex, 23.84 RW-shared, 44.41 RW-excl
------------
TRANSACTIONS
------------
Trx id counter 11882875981
Purge done for trx's n:o < 11882875606 undo n:o < 0 state: running but idle
History list length 1889
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 11882874682, not started
MySQL thread id 73473, OS thread handle 0x7fbaafdb6700, query id 100862972 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882874410, not started
MySQL thread id 73472, OS thread handle 0x7fbaca279700, query id 100862026 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875975, not started
MySQL thread id 73447, OS thread handle 0x7fbacf446700, query id 100867583 XXX.XXX.XXX.XXX root closing tables
select * from `sportsbook_maindb`.`feed_event_odds` where `sportsbook_maindb`.`feed_event_odds`.`feed_event_id` in ('1811069')
---TRANSACTION 0, not started
MySQL thread id 73442, OS thread handle 0x7fbab09f7700, query id 100839940 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882867252, not started
MySQL thread id 73426, OS thread handle 0x7fbacfb21700, query id 100836223 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875822, not started
MySQL thread id 73428, OS thread handle 0x7fbab9b7d700, query id 100866992 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 73423, OS thread handle 0x7fbaafbef700, query id 100831913 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882872555, not started
MySQL thread id 73325, OS thread handle 0x7fbac77be700, query id 100855753 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875960, not started
MySQL thread id 73326, OS thread handle 0x7fbacfef0700, query id 100867542 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882843879, not started
MySQL thread id 73320, OS thread handle 0x7fbab37be700, query id 100746169 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882853250, not started
MySQL thread id 73229, OS thread handle 0x7fbac76ba700, query id 100786064 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875978, not started
MySQL thread id 73231, OS thread handle 0x7fbabf2fb700, query id 100867594 XXX.XXX.XXX.XXX root Opening tables
select * from `sportsbook_maindb`.`feed_events` where (`feed_id` = ? and `provider_event_id` = ? and `type` = ? and `sport_id` = ? and `category_id` = ? and `tournament_id` = ?) limit 1
---TRANSACTION 11882822134, not started
MySQL thread id 73227, OS thread handle 0x7fbacfa1d700, query id 100661334 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882820779, not started
MySQL thread id 73051, OS thread handle 0x7fbac2679700, query id 100655871 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882830983, not started
MySQL thread id 73136, OS thread handle 0x7fbac27be700, query id 100698647 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 73133, OS thread handle 0x7fbab0b7d700, query id 100549256 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875805, not started
MySQL thread id 73052, OS thread handle 0x7fbab27ff700, query id 100867298 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882782336, not started
MySQL thread id 73046, OS thread handle 0x7fbab0bbe700, query id 100427035 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882820807, not started
MySQL thread id 73031, OS thread handle 0x7fbaaffbe700, query id 100656320 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882777845, not started
MySQL thread id 73024, OS thread handle 0x7fbac273c700, query id 100398964 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882753941, not started
MySQL thread id 72930, OS thread handle 0x7fbac26fb700, query id 100251756 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875973, not started
MySQL thread id 72931, OS thread handle 0x7fbac3fff700, query id 100867580 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882752465, not started
MySQL thread id 72923, OS thread handle 0x7fbac4fff700, query id 100241832 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875977, not started
MySQL thread id 72832, OS thread handle 0x7fbaafb6d700, query id 100867592 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882734325, not started
MySQL thread id 72825, OS thread handle 0x7fbac3fbe700, query id 100112673 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882732381, not started
MySQL thread id 72809, OS thread handle 0x7fbac777d700, query id 100100554 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875893, not started
MySQL thread id 72810, OS thread handle 0x7fbac75b6700, query id 100867279 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 72806, OS thread handle 0x7fbab0afb700, query id 100089215 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882861085, not started
MySQL thread id 72712, OS thread handle 0x7fbabf2ba700, query id 100815085 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875962, not started
MySQL thread id 72713, OS thread handle 0x7fbaca238700, query id 100867543 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 72709, OS thread handle 0x7fbac76fb700, query id 99960334 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882861460, not started
MySQL thread id 72694, OS thread handle 0x7fbacf342700, query id 100816387 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875979, not started
MySQL thread id 72695, OS thread handle 0x7fbabf33c700, query id 100867609 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882711034, not started
MySQL thread id 72692, OS thread handle 0x7fbac7679700, query id 99941737 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882861262, not started
MySQL thread id 72673, OS thread handle 0x7fbab37ff700, query id 100816282 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875804, not started
MySQL thread id 72674, OS thread handle 0x7fbacb5b6700, query id 100867297 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 72670, OS thread handle 0x7fbabf37d700, query id 99922018 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11881700879, not started
MySQL thread id 66986, OS thread handle 0x7fbabc7ff700, query id 93448633 185.81.238.240 root cleaning up
---TRANSACTION 0, not started
MySQL thread id 55432, OS thread handle 0x7fbaafdf7700, query id 75618608 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 7548, OS thread handle 0x7fbabc7be700, query id 100867611 185.81.238.240 root init
SHOW ENGINE INNODB STATUS
---TRANSACTION 0, not started
MySQL thread id 7538, OS thread handle 0x7fbac773c700, query id 100635363 185.81.238.240 root cleaning up
---TRANSACTION 11882245426, not started
MySQL thread id 31645, OS thread handle 0x7fbabf3ff700, query id 96827866 185.81.238.240 root cleaning up
---TRANSACTION 11882679493, not started
MySQL thread id 14852, OS thread handle 0x7fbac3f7d700, query id 99698982 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11873625990, not started
MySQL thread id 14125, OS thread handle 0x7fbaca1f7700, query id 99540454 185.81.238.240 root cleaning up
---TRANSACTION 0, not started
MySQL thread id 14109, OS thread handle 0x7fbac75f7700, query id 99547660 185.81.238.240 root cleaning up
---TRANSACTION 11868523434, not started
MySQL thread id 9205, OS thread handle 0x7fbac4fbe700, query id 12801623 185.81.238.240 root cleaning up
---TRANSACTION 11882248288, not started
MySQL thread id 1212, OS thread handle 0x7fbacff72700, query id 96849893 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11867848641, not started
MySQL thread id 6329, OS thread handle 0x7fbac27ff700, query id 8328197 185.81.238.240 root cleaning up
---TRANSACTION 11882672192, not started
MySQL thread id 1285, OS thread handle 0x7fbaca2fb700, query id 99644576 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882860394, not started
MySQL thread id 1392, OS thread handle 0x7fbacb5f7700, query id 100812088 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882868595, not started
MySQL thread id 1273, OS thread handle 0x7fbacb7ff700, query id 100841204 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875605, not started
MySQL thread id 1213, OS thread handle 0x7fbacfba3700, query id 100866459 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882559726, not started
MySQL thread id 1220, OS thread handle 0x7fbacfdab700, query id 100859394 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882873636, not started
MySQL thread id 1226, OS thread handle 0x7fbacb73c700, query id 100859395 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882248273, not started
MySQL thread id 1215, OS thread handle 0x7fbacfae0700, query id 96848359 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882875772, not started
MySQL thread id 1214, OS thread handle 0x7fbacf1bc700, query id 100866766 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11866588339, not started
MySQL thread id 1207, OS thread handle 0x7fbacf793700, query id 451924 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 1202, OS thread handle 0x7fbacfd29700, query id 450403 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882874899, not started
MySQL thread id 1210, OS thread handle 0x7fbacf8d8700, query id 100863723 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11866588171, not started
MySQL thread id 1208, OS thread handle 0x7fbacf856700, query id 450371 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 1203, OS thread handle 0x7fbacf3c4700, query id 447224 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11866588173, not started
MySQL thread id 1199, OS thread handle 0x7fbacfe2d700, query id 449824 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 1198, OS thread handle 0x7fbacfbe4700, query id 445625 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 1193, OS thread handle 0x7fbacfc66700, query id 445271 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 1191, OS thread handle 0x7fbacf919700, query id 444828 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 0, not started
MySQL thread id 1187, OS thread handle 0x7fbacf509700, query id 444521 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11866586787, not started
MySQL thread id 1180, OS thread handle 0x7fbacf815700, query id 435638 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882847402, not started
MySQL thread id 1165, OS thread handle 0x7fbacfb62700, query id 100755663 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882846956, not started
MySQL thread id 1174, OS thread handle 0x7fbacfe6e700, query id 100751802 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882854010, not started
MySQL thread id 1164, OS thread handle 0x7fbacf2c0700, query id 100783528 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882868602, not started
MySQL thread id 1175, OS thread handle 0x7fbacf383700, query id 100835995 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882867289, not started
MySQL thread id 1173, OS thread handle 0x7fbacf60d700, query id 100836224 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882868383, not started
MySQL thread id 1170, OS thread handle 0x7fbacf27f700, query id 100840305 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882852181, not started
MySQL thread id 1171, OS thread handle 0x7fbacf1fd700, query id 100780084 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882870222, not started
MySQL thread id 1172, OS thread handle 0x7fbacf4c8700, query id 100847395 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882852652, not started
MySQL thread id 1167, OS thread handle 0x7fbacf897700, query id 100782309 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882846493, not started
MySQL thread id 1166, OS thread handle 0x7fbacf487700, query id 100751540 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882851661, not started
MySQL thread id 1168, OS thread handle 0x7fbacfeaf700, query id 100776989 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882860508, not started
MySQL thread id 1169, OS thread handle 0x7fbacf23e700, query id 100809213 XXX.XXX.XXX.XXX root cleaning up
---TRANSACTION 11882874001, not started
MySQL thread id 1163, OS thread handle 0x7fbacf5cc700, query id 100857358 XXX.XXX.XXX.XXX root cleaning up
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
 ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
32109 OS file reads, 293736 OS file writes, 232781 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 43.93 writes/s, 22.91 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 35016, seg size 35018, 24 merges
merged operations:
 insert 22, delete mark 33, delete 28
discarded operations:
 insert 0, delete mark 0, delete 0
33987.71 hash searches/s, 12676.14 non-hash searches/s
---
LOG
---
Log sequence number 5161042928416
Log flushed up to   5161042928396
Pages flushed up to 5160903870455
Last checkpoint at  5160903858993
Max checkpoint age    869019772
Checkpoint age target 841862905
Modified age          139057961
Checkpoint age        139069423
0 pending log writes, 0 pending chkp writes
150467 log i/o's done, 14.02 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 11177820160; in additional pool allocated 0
Total memory allocated by read views 6056
Internal hash tables (constant factor + variable factor)
    Adaptive hash index 225887008   (169996984 + 55890024)
    Page hash           1329176 (buffer pool 0 only)
    Dictionary cache    44357318    (42500624 + 1856694)
    File system         1016392     (812272 + 204120)
    Lock system         26592536    (26563016 + 29520)
    Recovery system     0   (0 + 0)
Dictionary memory allocated 1856694
Buffer pool size        655352
Buffer pool size, bytes 10737287168
Free buffers            516293
Database pages          135648
Old database pages      6591
Modified db pages       4137
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 35523, not young 435533
0.00 youngs/s, 0.00 non-youngs/s
Pages read 31888, created 103783, written 81574
0.00 reads/s, 6.53 creates/s, 24.59 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 135648, unzip_LRU len: 0
I/O sum[11240]:cur[24], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size        81919
Buffer pool size, bytes 1342160896
Free buffers            63808
Database pages          17688
Old database pages      860
Modified db pages       738
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 12, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 4203, created 13485, written 13119
0.00 reads/s, 1.24 creates/s, 3.66 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17688, unzip_LRU len: 0
I/O sum[1405]:cur[3], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size        81919
Buffer pool size, bytes 1342160896
Free buffers            64232
Database pages          17262
Old database pages      839
Modified db pages       562
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 9792, not young 109004
0.00 youngs/s, 0.00 non-youngs/s
Pages read 4346, created 12919, written 10360
0.00 reads/s, 0.39 creates/s, 3.47 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 17262, unzip_LRU len: 0
I/O sum[1405]:cur[3], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size        81919
Buffer pool size, bytes 1342160896
Free buffers            64815
Database pages          16669
Old database pages      810
Modified db pages       476
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 8543, not young 77383
0.00 youngs/s, 0.00 non-youngs/s
Pages read 3728, created 12949, written 9935
0.00 reads/s, 0.34 creates/s, 2.61 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 16669, unzip_LRU len: 0
I/O sum[1405]:cur[3], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size        81919
Buffer pool size, bytes 1342160896
Free buffers            64752
Database pages          16742
Old database pages      813
Modified db pages       505
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 2, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 3869, created 12873, written 10276
0.00 reads/s, 0.37 creates/s, 3.02 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 16742, unzip_LRU len: 0
I/O sum[1405]:cur[3], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size        81919
Buffer pool size, bytes 1342160896
Free buffers            64542
Database pages          16953
Old database pages      824
Modified db pages       485
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 9168, not young 130820
0.00 youngs/s, 0.00 non-youngs/s
Pages read 4085, created 12872, written 10275
0.00 reads/s, 0.34 creates/s, 2.71 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 16953, unzip_LRU len: 0
I/O sum[1405]:cur[3], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size        81919
Buffer pool size, bytes 1342160896
Free buffers            64649
Database pages          16842
Old database pages      818
Modified db pages       503
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 5, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 3936, created 12906, written 9149
0.00 reads/s, 0.88 creates/s, 2.97 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 16842, unzip_LRU len: 0
I/O sum[1405]:cur[3], unzip sum[0]:cur[0]
---BUFFER POOL 6
Buffer pool size        81919
Buffer pool size, bytes 1342160896
Free buffers            64770
Database pages          16725
Old database pages      812
Modified db pages       369
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 3, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 4005, created 12720, written 8895
0.00 reads/s, 1.44 creates/s, 2.95 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 16725, unzip_LRU len: 0
I/O sum[1405]:cur[3], unzip sum[0]:cur[0]
---BUFFER POOL 7
Buffer pool size        81919
Buffer pool size, bytes 1342160896
Free buffers            64725
Database pages          16767
Old database pages      815
Modified db pages       499
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 7998, not young 118326
0.00 youngs/s, 0.00 non-youngs/s
Pages read 3716, created 13059, written 9565
0.00 reads/s, 1.53 creates/s, 3.20 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 16767, unzip_LRU len: 0
I/O sum[1405]:cur[3], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
2 read views open inside InnoDB
0 RW transactions active inside InnoDB
0 RO transactions active inside InnoDB
0 out of 1000 descriptors used
---OLDEST VIEW---
Normal read view
Read view low limit trx n:o 11882876173
Read view up limit trx id 11882876173
Read view low limit trx id 11882876173
Read view individually stored trx ids:
-----------------
Main thread process no. 9910, id 140440435156736, state: sleeping
Number of rows inserted 345653, updated 2558529, deleted 1158, read 1100668819
18.75 inserts/s, 560.38 updates/s, 0.00 deletes/s, 125493.04 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

我怎样才能找出问题所在?我读了很多关于 mysql 的文章,我试图终止连接,我试图删除 tmp 表,但我无法解决它。


我注意到你的许多 InnoDB 线程都停留在“清理”状态。

有一个错误https://bugs.mysql.com/bug.php?id=78777 https://bugs.mysql.com/bug.php?id=78777关于线程陷入该状态。据报道,该问题已在 MySQL 5.6.35、5.7.17、8.0.1 中修复。如果您还没有升级到这些版本,则应该升级到这些版本。

另一个建议是增加尺寸table_open_cache。监控状态变量Open_tables and Opened_tables.

更多阅读:

  • https://dev.mysql.com/doc/refman/5.7/en/table-cache.html https://dev.mysql.com/doc/refman/5.7/en/table-cache.html
  • https://dba.stackexchange.com/questions/45551/how-to-optimize-table-cache https://dba.stackexchange.com/questions/45551/how-to-optimize-table-cache一些提示。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我如何清理 mysql 上的临时表 的相关文章

  • 将第三个表链接到多对多关联中的桥接表

    设计这个数据库的正确方法是什么 这是我设置表格的方式 我在名为 教师 的表和名为 仪器 的表之间存在多对多关系 然后我有一个连接两者的桥接表 我想将另一个表与 BRIDGE 表关联起来 意思是乐器 老师的组合 该表有 3 行 指定老师可以教
  • 如何使用 vitess 仅对特定表进行分片

    我创建了一个包含三个表的未分片键空间 现在我想对前两个表的键空间进行分片 但不想对第三个表进行分片 如何才能做到这一点 Vitess 文档不包含任何与此相关的信息或示例 请帮忙 Thanks vitess 中的垂直分片与水平分片类似 您应该
  • MySQL连接字符集问题

    我在 Mac 上使用带有 MySQL 的 velosurf 没有任何编码问题 但是当我切换到 Linux 计算机时 从 velosurf 获得的值未正确编码 我发现这可能是默认连接字符集的问题 在 Mac 上我得到 mysql gt sho
  • PDO PHP 连接,致命错误

    我的连接类 firstcode php class DB functions public db function construct try db new PDO mysql localhost dbname xxx charset ut
  • 在 PHP 字符串中格式化 MySQL 代码

    是否有任何程序 IDE 可以在 PHP 字符串中格式化 MySQL 代码 例如 我使用 PHPStorm IDE 但它无法做到这一点 它对 PHP 和 MYSQL 执行此操作 但不适用于 php 字符串内的 MYSQL 我已准备好使用新的
  • 如何从shell脚本自动登录MySQL?

    我有一个 MySQL 服务器 其中有一个用户和密码 我想在 shell 脚本中执行一些 SQL 查询而不指定密码 如下所示 config sh MYSQL ROOT root MYSQL PASS password mysql sh sou
  • 一次从多个表中删除行

    我正在尝试将 2 个查询合并为一个这样的查询 result db gt query DELETE FROM menu WHERE name new or die db gt error result db gt query DELETE F
  • 在 MySQL 中存储表情符号的编码问题:如何使用 Prisma ORM 在 NodeJS 中定义字符排序规则?

    亲爱的 Nodejs 专家和数据库专家 我们在 MySQL 数据库中存储表情符号和其他特殊字符时遇到问题 我们使用 Prisma 得到一个错误 这是我们使用的 ORM 参数无法从排序规则 utf8 general ci 转换为 utf8mb
  • MySql - 复制监控工具[关闭]

    Closed 此问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我有一个主 从 MySql 复制 我正在寻找一个允许我监视复制的工具 查看它没有错误 检查滞后等 我更喜
  • 海量记录的bulk_create最佳实践

    I use bulk create将 1 mio 记录插入到新表中 需要 80 秒 Django 只使用一个 CPU 核心 大约 25 CPU 但没有一个核心达到 100 我相信有改进的潜力 这是代码 class Stock models
  • 在 C# 中,当有人插入、删除或修改记录时,如何从 MySQL 获取事件?

    我正在 WPF Net 中开发一个程序 我需要知道何时有人对数据库的任何表进行更改 这个想法是在数据库发生更改时从数据库接收一个事件 我读了很多文章 但找不到解决我的问题的方法 亲切的问候 最好的解决方案是使用消息队列 在您的应用程序向数据
  • MySQL - 从临时表插入

    这看起来非常简单 但我坚持使用简单的插入语句 见下文 begin work CREATE TEMPORARY TABLE IF NOT EXISTS insert table AS select r resource id fr file
  • 如何在 MySQL 中求和时间?

    正如您在图片中看到的 我有一份停机报告 显示了所选工厂在选定日期的停机时间 现在我想添加所有的值 Time Duration 列并将其显示在附近的单独显示中 TOTAL TIME DURATION 例如 在图像中 所选日期为 2015 年
  • MySQL 和 Hibernate 之间的主键自增由谁负责?

    MySQL CREATE TABLE role id role INT 11 unsigned NOT NULL AUTO INCREMENT PRIMARY KEY id role AUTO INCREMENT 1 休眠 Entity p
  • MySql 5.7 ORDER BY 子句不在 GROUP BY 子句中并且包含非聚合列

    我试图在不禁用 my ini 中的 only full group by 的情况下弄清楚 这是我的查询 SELECT p title COUNT t qty AS total FROM payments t LEFT JOIN produc
  • MySQL 8 用逗号分割字符串并将其转换为JSON ARRAY

    我有以下字符串 a b c d 我想将它转换成一个 json 数组 像这样 a b c d MySQL 8 有什么函数可以实现这个功能吗 Try SELECT CAST CONCAT REPLACE a b c d AS JSON See
  • 即使没有结果也返回一个值

    我有这种简单的查询 它返回给定 id 的非空整数字段 SELECT field1 FROM table WHERE id 123 LIMIT 1 问题是如果找不到 id 结果集就是空的 我需要查询始终返回一个值 即使没有结果 我有这个东西工
  • libmysqlclient.a 和 libmysqlclient_r.a 有什么区别?

    我应该使用哪个来链接 mysqlclient 库 它们之间有什么区别 我似乎找不到答案 谢谢 较新版本的 MySQL 客户端发行版不包含 r 版本 有些可能有从 libmyqslclient r a 到 libmyqslclient a 的
  • 错误代码:1305。函数或过程不存在

    因此 我在 MySQL 中创建一个函数 然后尝试向用户授予使用该函数的权限 但我无法这样做 这就是我正在做的 DELIMITER USE rxhelp36 scbn DROP FUNCTION IF EXISTS businessDayDi
  • 让登录更安全

    我已使用此代码进行管理员登录 仅当用户输入正确的用户名和密码时才应打开loginhome php 但后来我意识到这根本不安全 任何人都可以直接访问 mywebsite loginhome php 而无需登录 注销后 可以使用后退按钮打开 l

随机推荐