I am using below select query to search from the table.
"Select * from authentication_codes where client_id=6"
column client_id is of type integer and i have also indexed that column. There are total 36751694
records in the table authentication_codes
and out of that 20200000
belongs to client_id 6.
Whenever i hit above SQL query 4 times simultaneously that time mysql is crashing with error "mysql server gone away"
and CPU utilization goes to 95%.
output with explain command for same query is as below
mysql> explain Select * from authentication_codes where client_id=6 \G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: authentication_codes
type: ref
possible_keys: index_authentication_codes_on_client_id
key: index_authentication_codes_on_client_id
key_len: 5
ref: const
rows: 18475849
Extra: Using where
1 row in set (0.00 sec)
After hitting 3 SQL request statement simultaneously CPU utilization with top command is as below
top - 09:13:43 up 2:28, 4 users, load average: 1.94, 0.67, 0.52
Tasks: 123 total, 2 running, 121 sleeping, 0 stopped, 0 zombie
%Cpu(s): 91.0 us, 2.8 sy, 0.0 ni, 5.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.4 st
KiB Mem: 4046840 total, 2439948 used, 1606892 free, 6836 buffers
KiB Swap: 0 total, 0 used, 0 free. 1929160 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4543 mysql 20 0 886304 176544 7068 S 188.0 4.4 2:53.83 mysqld
My server has 4GB of ram and 2 CPU core. Mysql table is using database engine Innodb.
Thanks,