I'm having following table structure.
reservation: (InnoDB)
------------------------------------------
id INT,
date DATE,
item_id INT,
slot VARCHAR(50);
PRIMARY KEY(id), UNIQUE KEY(item_id,date).
Now i'm trying to use SELECT.....FOR UPDATE on reservation table inside a transaction to lock specific rows within date range(eg:2012-06-15 to 2012-06-16) of a particular item_id.
SELECT availability FROM reservation WHERE item_id={$item_id} AND (date>='{$to_date}' AND date<='{$from_date}') FOR UPDATE
NOW when i use the above statement, it is blocking all the rows of particular item_id even beyond the date range.I'm also using this UNIQUE KEY(item_id,date).
How to lock only particular date range of a specific item_id?
regards,
ravi.
ADDED:
|
=====================================
120615 20:14:13 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 24 seconds
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 12, signal count 12
Mutex spin waits 0, rounds 180, OS waits 4
RW-shared spins 10, OS waits 5; RW-excl spins 2, OS waits 2
------------
TRANSACTIONS
------------
Trx id counter 0 15147
Purge done for trx's n:o < 0 15136 undo n:o < 0 0
History list length 2
Total number of lock structs in row lock hash table 2
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 0, not started, OS thread id 2940
MySQL thread id 76, query id 1487 localhost 127.0.0.1 root
SHOW innodb status
---TRANSACTION 0 15143, not started, OS thread id 2588
MySQL thread id 10, query id 578 localhost 127.0.0.1 root
---TRANSACTION 0 15144, ACTIVE 11526 sec, OS thread id 2740
3 lock struct(s), heap size 320
MySQL thread id 11, query id 577 localhost 127.0.0.1 root
--------
FILE I/O
--------
I/O thread 0 state: wait Windows aio (insert buffer thread)
I/O thread 1 state: wait Windows aio (log thread)
I/O thread 2 state: wait Windows aio (read thread)
I/O thread 3 state: wait Windows aio (write thread)
Pending normal aio reads: 0, aio writes: 0,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
187 OS file reads, 75 OS file writes, 29 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2,
0 inserts, 0 merged recs, 0 merges
Hash table size 62383, used cells 0, node heap has 1 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 0 8287163
Log flushed up to 0 8287163
Last checkpoint at 0 8287163
0 pending log writes, 0 pending chkp writes
24 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 23277934; in additional pool allocated 1430400
Buffer pool size 960
Free buffers 895
Database pages 64
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages read 64, created 0, written 51
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Main thread id 1544, state: waiting for server activity
Number of rows inserted 10, updated 0, deleted 0, read 66
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
|
Related
I have one server in replication. Whenever I am executing a delete query with a limit of 10000 or 100000 on InnoDB table then it returns me Error 1206 so that's why I have started to look into engine status which may help for better performance.
mysql> delete from cdrs where billseconds=0 limit 10000;
ERROR 1206 (HY000): The total number of locks exceeds the lock table size
But still, A beginner does not get enough understanding of what value can be correct or how to calculate which variable needs to be set up properly.
So anyone please suggest which value should be recommended?
mysql> SHOW ENGINE INNODB STATUS\G;
*************************** 1. row ***************************
Type: InnoDB
Name:
Status:
=====================================
2022-06-25 08:05:35 139698390398720 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 5 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 315147 srv_active, 0 srv_shutdown, 1711532 srv_idle
srv_master_thread log flush and writes: 0
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 107425397
OS WAIT ARRAY INFO: signal count 138090595
RW-shared spins 0, rounds 0, OS waits 0
RW-excl spins 0, rounds 0, OS waits 0
RW-sx spins 0, rounds 0, OS waits 0
Spin rounds per wait: 0.00 RW-shared, 0.00 RW-excl, 0.00 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 5868831
Purge done for trx's n:o < 5868831 undo n:o < 0 state: running but idle
History list length 0
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421173985799384, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985803424, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985802616, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985801808, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985801000, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985800192, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985798576, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421173985797768, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
--------
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] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:
Pending flushes (fsync) log: 0; buffer pool: 193
184939997 OS file reads, 408993938 OS file writes, 191478723 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 3093, seg size 3095, 64998391 merges
merged operations:
insert 905575573, delete mark 16719939, delete 5094846
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 4 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 759200638267
Log buffer assigned up to 759200638267
Log buffer completed up to 759200638267
Log written up to 759200638267
Log flushed up to 759200638267
Added dirty pages up to 759200638267
Pages flushed up to 759200638267
Last checkpoint at 759200638267
205244131 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 0
Dictionary memory allocated 2465252
Buffer pool size 8192
Free buffers 5735
Database pages 2447
Old database pages 922
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 18667218, not young 4562179027
0.00 youngs/s, 0.00 non-youngs/s
Pages read 184946579, created 25133992, written 155280433
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 2447, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=17499, Main thread ID=139698522695424 , state=sleeping
Number of rows inserted 1052202547, updated 1185599, deleted 18772945, read 2858392871
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
Number of system rows inserted 5488, updated 2933689, deleted 72, read 2992114
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
1 row in set (0.00 sec)
ERROR:
No query specified
My system memory :
root#ankitdoshi:/home/ankitdoshi# grep MemTotal /proc/meminfo
MemTotal: 131932092 kB
Thanks in advance for your help and suggestions.
By default, MySQL allocates 128MB of space for innodb_buffer_pool_size. To resolve the problem, you'll have to increase the size in /etc/my.cnf file
Edit /etc/my.cnf file, and add the following under the [mysqld] heading.
innodb_buffer_pool_size=256M
after that You'll have to tweak the value of innodb_buffer_pool_size as having large buffer size could introduce Fatal error: cannot allocate memory for the buffer pool problem. You'll have to restart the mysqld service in order to take this new value into effect.
service mysqld restart
Look here enter link description here
Don't delete more than 1000 rows in a chunk, else you hit issues like the one you encountered.
Even better is to avoid big deletes. There are several techniques: http://mysql.rjweb.org/doc.php/deletebig
And, yes, do increase innodb_buffer_pool_size to about 70% of available RAM.
I'm currently import a large CSV file and I'm trying to understand the logs that are coming into my error.log file. The import keeps on going, so this might be nothing, but given that it's logged into the error.log file with a default set-up, and I have no idea what to make out of it, it might be time for me to learn something by reaching out to the MariaDB community.
The log I'm getting is the following:
=====================================
2021-09-30 21:03:22 0x7f0848d41640 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 20 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 564 srv_active, 0 srv_shutdown, 1068 srv_idle
srv_master_thread log flush and writes: 1632
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 309014
--Thread 139674486203968 has waited at trx0undo.cc line 777 for 436.00 seconds the semaphore:
Mutex at 0x56464c440288, Mutex REDO_RSEG created trx0rseg.cc:397, lock var 2
--Thread 139673591895616 has waited at buf0flu.cc line 1214 for 431.00 seconds the semaphore:
SX-lock on RW-latch at 0x7f085fda1ab0 created in file buf0buf.cc line 1563
a writer (thread id 139673460528704) has reserved it in mode exclusive
number of readers 0, waiters flag 1, lock_word: 0
Last time write locked in file trx0rseg.ic line 43
OS WAIT ARRAY INFO: signal count 1296199
RW-shared spins 1239237, rounds 9381718, OS waits 207220
RW-excl spins 865910, rounds 6692891, OS waits 88463
RW-sx spins 375, rounds 11083, OS waits 365
Spin rounds per wait: 7.57 RW-shared, 7.73 RW-excl, 29.55 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 429
Purge done for trx's n:o < 425 undo n:o < 87636886 state: running
History list length 1
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 428, ACTIVE 1482 sec inserting
mysql tables in use 1, locked 1
1 lock struct(s), heap size 1128, 0 row lock(s), undo log entries 51774178
MySQL thread id 48, OS thread handle 139674486203968, query id 78 localhost root Reading file
LOAD DATA INFILE 'file.csv' INTO TABLE TABLE_X
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
lines terminated by '\r\n'
IGNORE 1 LINES
--------
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] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 1
452318 OS file reads, 589584 OS file writes, 172513 OS fsyncs
66.75 reads/s, 16384 avg bytes/read, 134.49 writes/s, 134.49 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 104 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 237726885168
Log flushed up to 237726880386
Pages flushed up to 237724062470
Last checkpoint at 237724062470
0 pending log flushes, 0 pending chkp writes
3473 log i/o's done, 0.95 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 405471232
Dictionary memory allocated 24640
Buffer pool size 8192
Free buffers 0
Database pages 8088
Old database pages 3003
Modified db pages 3448
Percent of dirty pages(LRU & free pages): 42.626
Max dirty pages percent: 75.000
Pending reads 0
Pending writes: LRU 0, flush list 2, single page 1
Pages made young 1119, not young 211124188
0.00 youngs/s, 200.24 non-youngs/s
Pages read 452305, created 195449, written 499116
66.75 reads/s, 0.00 creates/s, 66.75 writes/s
Buffer pool hit rate 900 / 1000, young-making rate 0 / 1000 not 298 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 8088, unzip_LRU len: 0
I/O sum[27390]:cur[946], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=37451, Main thread ID=139673583502912, state: sleeping
Number of rows inserted 51774178, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
Number of system rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
I believe this is an output due to something timing out, but I have no idea as to what "that" could be. The import doesn't stop either, it just continues on. Any help (or pointers) on dissecting this log would be greatly appreciated!
MariaDB, myphpadmin
I dropped a table due to issues with creating FK constraint. I am trying to recreate the table but it seems like the FK constraint is still in the DB somewhere. I cannot delete as there is no reference to it, that I can see anyway. I have no idea where to look to drop the constraint
Trying to create the table I get the following error.
=====================================
2020-03-04 18:58:15 0x14c6100cc700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 40 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 82 srv_active, 0 srv_shutdown, 53679 srv_idle
srv_master_thread log flush and writes: 53761
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 467
OS WAIT ARRAY INFO: signal count 372
RW-shared spins 0, rounds 1085, OS waits 396
RW-excl spins 0, rounds 4555, OS waits 20
RW-sx spins 3, rounds 34, OS waits 1
Spin rounds per wait: 1085.00 RW-shared, 4555.00 RW-excl, 11.33 RW-sx
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2020-03-04 18:58:14 0x14c610081700 Error in foreign key constraint of table moviesdb/movie_genre:
there is no index in the table which would contain
the columns as the first columns, or the data types in the
table do not match the ones in the referenced table
or one of the ON ... SET NULL columns is declared NOT NULL. Constraint:
,
CONSTRAINT `genre_id_fk` FOREIGN KEY (`genre_id`) REFERENCES `genre` (`genre_id`) ON DELETE CASCADE ON UPDATE CASCADE
------------
TRANSACTIONS
------------
Trx id counter 237460
Purge done for trx's n:o < 237460 undo n:o < 0 state: running
History list length 1
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 304315944137048, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 304315944132792, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
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] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
5389 OS file reads, 3086 OS file writes, 1050 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.55 writes/s, 0.20 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 69257, node heap has 1 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 1 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 3 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
0.07 hash searches/s, 1.10 non-hash searches/s
---
LOG
---
Log sequence number 845237404
Log flushed up to 845237404
Pages flushed up to 845237404
Last checkpoint at 845237395
0 pending log flushes, 0 pending chkp writes
673 log i/o's done, 0.10 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 285212672
Dictionary memory allocated 847024
Buffer pool size 16030
Free buffers 10583
Database pages 5432
Old database pages 2018
Modified db pages 0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 75.000
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 5071, created 361, written 2302
0.00 reads/s, 0.10 creates/s, 0.40 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: 5432, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=488, Main thread ID=22840912578304, state: sleeping
Number of rows inserted 820, updated 2, deleted 4, read 134187
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
Number of system rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
The error message is right there in the log:
Error in foreign key constraint of table moviesdb/movie_genre
there is no index in the table which would contain
the columns as the first columns, or the data types in the
table do not match the ones in the referenced table
So basically this means that
either the datatype and length of column genre_id in table movie_genre is not the same as column genre_id in table genre
or: there is no index on genre (genre_id) (or in which genre_id appears first); if so, this would indicate another flaw with your table structure as, most probably, genre_id should be the primary key of the genre table.
There is an InnoDB table:
id PRIMARY AI
id2 INDEX varchar
data LONGTEXT - contains 100k to 5 MB of text
mark_for_delete TINYINT
NUM ROWS = approx. 25000
SIZE=1.7G
MySQL 5.5
UPDATE table SET data='longtext here' WHERE id2=5
works fast
UPDATE table SET mark_for_delete=1 WHERE id2=5
works for 40 seconds
DELETE FROM table WHERE id2=5
works for 40 seconds
Deleting several rows takes the same time.
The disk reads data at a rate of 40Mb/s while executing last two queries.
How can I speed up updates and deletes?
Added from comment:
CREATE TABLE b.table (
id INT( 11 ) NOT NULL AUTO_INCREMENT ,
TradeCardId VARCHAR( 255 ) NOT NULL ,
TradeCardHTML LONGTEXT NOT NULL ,
MarkForDelete TINYINT( 4 ) NOT NULL DEFAULT '0',
PRIMARY KEY ( id ) ,
KEY TradeCardId ( TradeCardId )
) ENGINE = INNODB DEFAULT CHARSET = utf8;
INNODB SHOW STATUS while running a slow query:
=====================================
150712 4:51:15 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 28 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 1172 1_second, 1172 sleeps, 113 10_second, 56 background, 56 flush
srv_master_thread log flush and writes: 1224
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 921, signal count 923
Mutex spin waits 1470, rounds 11716, OS waits 206
RW-shared spins 645, rounds 18932, OS waits 569
RW-excl spins 5, rounds 4309, OS waits 142
Spin rounds per wait: 7.97 mutex, 29.35 RW-shared, 861.80 RW-excl
------------
TRANSACTIONS
------------
Trx id counter 7B100A
Purge done for trx's n:o < 7B1006 undo n:o < 0
History list length 2752
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 411, OS thread handle 0x29fc, query id 62926 localhost 127.0.0.1 root
SHOW ENGINE INNODB STATUS
---TRANSACTION 7B05CE, not started
MySQL thread id 269, OS thread handle 0xf6c, query id 58184 localhost 127.0.0.1 root
---TRANSACTION 7AEA37, not started
MySQL thread id 268, OS thread handle 0x142c, query id 45581 localhost 127.0.0.1 root
---TRANSACTION 7B0FF6, not started
MySQL thread id 267, OS thread handle 0x1cc, query id 62861 localhost 127.0.0.1 root
---TRANSACTION 7AE808, not started
MySQL thread id 266, OS thread handle 0xa84, query id 44520 localhost 127.0.0.1 root
---TRANSACTION 7AEBF1, not started
MySQL thread id 133, OS thread handle 0x24ac, query id 46431 localhost 127.0.0.1 root
---TRANSACTION 7ACEE4, not started
MySQL thread id 116, OS thread handle 0x1970, query id 32435 localhost 127.0.0.1 root
---TRANSACTION 7AD73D, not started
MySQL thread id 85, OS thread handle 0xfb8, query id 36383 localhost 127.0.0.1 root
---TRANSACTION 7AEA14, not started
MySQL thread id 84, OS thread handle 0x2b10, query id 45519 localhost 127.0.0.1 root
---TRANSACTION 7ACEC0, not started
MySQL thread id 83, OS thread handle 0x17e8, query id 32180 localhost 127.0.0.1 root
---TRANSACTION 7AD7A5, not started
MySQL thread id 81, OS thread handle 0x2900, query id 36585 localhost 127.0.0.1 root
---TRANSACTION 7AF77F, not started
MySQL thread id 56, OS thread handle 0x1a1c, query id 51611 localhost 127.0.0.1 root
---TRANSACTION 7ACEA2, not started
MySQL thread id 3, OS thread handle 0x2080, query id 31915 localhost 127.0.0.1 root
---TRANSACTION 7B069A, not started
MySQL thread id 2, OS thread handle 0x2a2c, query id 58548 localhost 127.0.0.1 root
---TRANSACTION 7A5300, not started
MySQL thread id 1, OS thread handle 0x2188, query id 3 localhost 127.0.0.1 root
---TRANSACTION 7B1009, ACTIVE 42 sec fetching rows
mysql tables in use 1, locked 1
277 lock struct(s), heap size 27968, 5127 row lock(s)
MySQL thread id 82, OS thread handle 0x21c8, query id 62893 localhost 127.0.0.1 root updating
DELETE FROM `tradecards_raw` WHERE `TradeCardId`=430931
--------
FILE I/O
--------
I/O thread 0 state: wait Windows aio (insert buffer thread)
I/O thread 1 state: wait Windows aio (log thread)
I/O thread 2 state: wait Windows aio (read thread)
I/O thread 3 state: wait Windows aio (read thread)
I/O thread 4 state: wait Windows aio (read thread)
I/O thread 5 state: wait Windows aio (read thread)
I/O thread 6 state: wait Windows aio (write thread)
I/O thread 7 state: wait Windows aio (write thread)
I/O thread 8 state: wait Windows aio (write thread)
I/O thread 9 state: wait Windows aio (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: 1
Pending flushes (fsync) log: 0; buffer pool: 0
295450 OS file reads, 69254 OS file writes, 3663 OS fsyncs
375.38 reads/s, 16384 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 5, seg size 7, 4 merges
merged operations:
insert 29, delete mark 2, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 4425293, node heap has 1 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 16969722405
Log flushed up to 16969722405
Last checkpoint at 16969722405
0 pending log writes, 0 pending chkp writes
41513 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 1087897600; in additional pool allocated 0
Dictionary memory allocated 28146
Buffer pool size 65536
Free buffers 0
Database pages 65534
Old database pages 24171
Modified db pages 0
Pending reads 1
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 261024, not young 0
375.34 youngs/s, 0.00 non-youngs/s
Pages read 295310, created 13003, written 26379
375.34 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 555 / 1000, young-making rate 445 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 370.24/s, Random read ahead 0.00/s
LRU len: 65534, unzip_LRU len: 0
I/O sum[20617]:cur[77], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Main thread id 2256, state: waiting for server activity
Number of rows inserted 37683, updated 2503, deleted 65762, read 18023414
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 92.46 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
Which ENGINE? (Please provide full SHOW CREATE TABLE.) It sounds like you are using MyISAM. If so read on. (If InnoDB, I am surprised at the 40 seconds.)
This may be a case where you should use "vertical partitioning". That is, put the LONGTEXT in a parallel table with the same primary key. When SELECTing data..., use a JOIN. When marking for delete, you don't need to touch the second table. The other two queries would need a JOIN, but still might be faster.
Edit
Since id2 is VARCHAR, change id2=5 to id2="5" to keep it from converting to numeric.
I performed a schema alteration which involved (among other things) two linked tables.
DROP TABLE `Bump`; # this used to have a foreign key to Place
ALTER TABLE `Place`
...
DROP PRIMARY KEY, #it used to be a composite key from two decmals
ADD PRIMARY KEY (`id`) USING BTREE;
After that, I tried to change the engine of the table:
ALTER TABLE `Place` ENGINE = MyISAM;
But it gives me:
mysql> ALTER TABLE `mydb`.`Place` ENGINE = MyISAM;
ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
This happens consistently for a brand-new table. Here is the trace below. But in an empty table, it does not say anything.
But for a previously populated Place, it had mentioned the Bump table by name. Why is this happening to me, when the parent table does not have its previous primary key and the child table does not exist?
I am converting to MyISAM to avoid transactions overhead for a large number of inserts.
mysql> show engine innodb status;
+--------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Type | Name | Status |
+--------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| InnoDB | |
=====================================
120806 18:49:20 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 28 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 1 1_second, 1 sleeps, 0 10_second, 1 background, 1 flush
srv_master_thread log flush and writes: 1
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 3, signal count 3
Mutex spin waits 1, rounds 30, OS waits 1
RW-shared spins 2, rounds 60, OS waits 2
RW-excl spins 0, rounds 0, OS waits 0
Spin rounds per wait: 30.00 mutex, 30.00 RW-shared, 0.00 RW-excl
------------
TRANSACTIONS
------------
Trx id counter 2D00
Purge done for trx's n:o < 2BB0 undo n:o < 0
History list length 2467
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 37, OS thread handle 0xa6affb40, query id 182 localhost root
show engine innodb status
---TRANSACTION 0, not started
MySQL thread id 36, OS thread handle 0xb625ab40, query id 177 localhost 127.0.0.1 root
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (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
671 OS file reads, 3 OS file writes, 3 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 553193, node heap has 2 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 10825171
Log flushed up to 10825171
Last checkpoint at 10825171
0 pending log writes, 0 pending chkp writes
8 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 135987200; in additional pool allocated 0
Dictionary memory allocated 358285
Buffer pool size 8191
Free buffers 7529
Database pages 660
Old database pages 263
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 660, created 0, written 0
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 660, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Main thread process no. 26970, id 2791775040, state: waiting for server activity
Number of rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
|
+--------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
It seems that there must be another foreign key on the table (or linking to the table).
What do you get back from 'show create table mydb.Place'?