我如何清理 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 上的临时表 的相关文章

  • 删除ID最小的记录

    当我在 MySQL 中输入此查询时 DELETE FROM myTable WHERE ID SELECT Min ID FROM myTable 我收到以下错误消息 1093 You can t specify target table
  • 资源 ID #4 PHP MYSQL

    result mysql query SELECT indvsum sum1 indvsum sum2 FROM SELECT SUM Cash AS sum1 SUM Bank AS sum2 FROM players indvsum e
  • 如何使用mac杀死mysql进程

    I used ps ax grep mysql检查mysql进程是否存在 我发现 5323 s000 S 0 00 00 grep mysql 我想终止该进程 但号码自动更改 当我进入ps ax grep mysql 内容变化如下 5507
  • PHP 内部的连接分解

    我看到一篇关于连接分解的文章 场景 1 不好 Select from tag Join tag post ON tag post tag id tag id Join post ON tag post post id post id Whe
  • 匹配 MySQL 中单词/后缀的相似/变体

    我如何匹配 MySQL 中单词的变体 例如搜索 accountancy 应匹配 accountant accountants accounting 等 我使用共享主机 因此无法向 MySQL 添加任何功能 例如 levenshtein 我想
  • 每次使用 COUNT() 函数,还是存储该值并将其加一?

    我有一个带有用户 投票 表和 用户 表的数据库 我认为数据库会在短时间内变得相当大 所以我想使用最有效的方法 我想我可以每次使用 投票 表中的 WHERE 语句来 COUNT 投票数 或者我可以将分数存储在 用户 表中 每次投票时将其增加
  • 如何使用mysqli准备好的语句?

    我正在尝试准备好的语句 但下面的代码不起作用 我收到错误 致命错误 在非对象上调用成员函数execute var www prepared php 第 12 行
  • 使用java将数据插入mySQL表

    I have a predefined table in a mySQL database 我正在努力将从用户输入的数据保存到数据库中 但我似乎无法将任何数据保存在数据库中 使用以下代码 我尝试更新数据库的第一行 ID 1 到 OTHER
  • 如何使用 Laravel 查询生成器在 WHERE 条件周围添加括号

    我使用 Laravel 查询构建器根据用户的过滤器选择动态过滤数据 query DB table readings foreach selections as selection query gt orWhere id selection
  • PHP、MySQL、PDO 事务 - fetchAll() 可以在 commit() 之前吗?

    更多交易问题 我现在拥有的是一堆串在一起的查询 如果有任何失败 都会手动反转 代码块1 stmt1 db gt prepare Update table1 set col col 1 if stmt1 db gt execute stmt2
  • 让网站登录也能在 WordPress 上使用

    我使用 PHP 和 MySQL 开发了一个网站 该网站已经有登录和注册表单 myweb com 我已经在这个网址添加了 wordpressmyweb com blog 我想禁用 WordPress 上的登录和注册页面并强制用户使用我的 基本
  • 数据库表可以没有主键吗?

    谁能告诉我关系数据库 例如MySQL SQL SERVER 中的表是否可以没有主键 例如 我可以有桌子day temperature 我注册的地方temperature and time 我不明白为什么要为这样的表设置主键 从技术上讲 您可
  • 根据另一个表中的值查找总计数

    在Mysql中 我的表中有具有重复值的城市 表城市 Name New York USA New York USA Chicago USA Chicago USA Chicago USA Paris France Nice France Mi
  • mysql中更新查询中的多个set和where子句

    我认为这是不可能的 因为我找不到任何东西 但我想我会在这里检查一下 以防我没有寻找正确的东西 我的数据库中有一个设置表 其中有两列 第一列是设置名称 第二列是值 我需要同时更新所有这些 我想看看是否有一种方法可以在一个查询的同时更新这些值
  • MySQL如何获取可能重叠日期的开始/结束日期之和

    我有一个开始 结束日期表 我想按 id 对其进行分组并对每个 id 的总时间进行求和 例如 fk id start end 3 2014 03 21 10 02 2014 05 01 08 05 3 2014 06 05 05 00 201
  • MySQL 的 read_sql() 非常慢

    我将 MySQL 与 pandas 和 sqlalchemy 一起使用 然而 它的速度非常慢 对于一个包含 1100 万行的表 一个简单的查询需要 11 分钟以上才能完成 哪些行动可以改善这种表现 提到的表没有主键 并且仅由一列索引 fro
  • 选择当前项目 id 周围的 N 个上一个项目和 M 个下一个项目

    我有一张有照片的桌子 id year comm count 0 2015 1 1 2016 2 2 2017 5 3 2018 7 4 2019 1 5 2020 9 6 2021 1 7 2022 1 我选择具有给定 ID 的照片 位于所
  • 如何在应用程序级别管理只读数据库连接

    我们使用的是Java Spring Ibatis MySql 有没有办法利用这些技术在应用程序级别管理只读连接 我希望在只读 MySql 用户的基础上添加额外的保护层 如果 BasicDataSource 或 SqlMapClientTem
  • 用户登录时如何更新updated_at列?

    我正在尝试更新updated at每次用户登录时 列到当前时间 但我收到以下错误 InvalidArgumentException 找不到四位数年份 数据丢失 PHP input Input all remember Input has r
  • 发送 QUERY 数据包时出错。 PID=9565

    我有两个不同的环境开发和生活几乎都是相同的 但上述 标题中 警告仅在开发模式下发生 在此警告之前 我还收到错误消息 允许的内存大小 268435456 字节已耗尽 这仅发生在开发模式下 使用 PHP 版本 5 6 和 mysql 不是 my

随机推荐