MariaDB [test]> SELECT COUNT(1) FROM sceb205fa121 sch WHERE EXISTS (SELECT 1 FROM ed8ec6a6b8d1 WHERE dia34a99d3bc = sch.dia34a99d3bc AND moc979966566 = 4 AND ye91b4a70018 = 34 ) AND EXISTS (SELECT 1 FROM us23a3719e74 usr INNER JOIN di569c818b1e dis ON usr.dia34a99d3bc = dis.idb80bb77402 WHERE usr.st9ed39e2ea9 = 0 AND usr.dia34a99d3bc = sch.dia34a99d3bc AND usr.ty94757cae63 IN (3, 4, 5)); +----------+ | COUNT(1) | +----------+ | 2010407 | +----------+ 1 row in set (0.70 sec) MariaDB [test]> SELECT COUNT(1) FROM sceb205fa121; +----------+ | COUNT(1) | +----------+ | 469 | +----------+ 1 row in set (0.00 sec) MariaDB [test]> SELECT COUNT(1) FROM sceb205fa121 sch WHERE EXISTS (SELECT 1 FROM ed8ec6a6b8d1 WHERE dia34a99d3bc = sch.dia34a99d3bc AND moc979966566 = 4 AND ye91b4a70018 = 34 ) AND EXISTS (SELECT 1 FROM us23a3719e74 usr INNER JOIN di569c818b1e dis ON usr.dia34a99d3bc = dis.idb80bb77402 WHERE usr.st9ed39e2ea9 = 0 AND usr.dia34a99d3bc = sch.dia34a99d3bc AND usr.ty94757cae63 IN (3, 4, 5)); +----------+ | COUNT(1) | +----------+ | 2010407 | +----------+ 1 row in set (0.00 sec) MariaDB [test]> DESC us23a3719e74; +--------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+---------------------+------+-----+---------+-------+ | dia34a99d3bc | int(11) | YES | MUL | NULL | | | st9ed39e2ea9 | tinyint(3) unsigned | NO | | NULL | | | ty94757cae63 | int(11) | NO | MUL | NULL | | +--------------+---------------------+------+-----+---------+-------+ 3 rows in set (0.00 sec) MariaDB [test]> SHOW CREATE TABLE us23a3719e74; +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | us23a3719e74 | CREATE TABLE `us23a3719e74` ( `dia34a99d3bc` int(11) DEFAULT NULL, `st9ed39e2ea9` tinyint(3) unsigned NOT NULL, `ty94757cae63` int(11) NOT NULL, KEY `dia34a99d3bc` (`dia34a99d3bc`), KEY `ty94757cae63` (`ty94757cae63`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) MariaDB [test]> SELECT COUNT(1) FROM sceb205fa121 sch WHERE EXISTS (SELECT 1 FROM ed8ec6a6b8d1 WHERE dia34a99d3bc = sch.dia34a99d3bc AND moc979966566 = 4 AND ye91b4a70018 = 34 ) AND EXISTS (SELECT 1 FROM us23a3719e74 usr INNER JOIN di569c818b1e dis ON usr.dia34a99d3bc = dis.idb80bb77402 WHERE usr.st9ed39e2ea9 = 0 AND usr.dia34a99d3bc = sch.dia34a99d3bc AND usr.ty94757cae63 IN (3, 4, 5)); +----------+ | COUNT(1) | +----------+ | 2010407 | +----------+ 1 row in set (0.00 sec) MariaDB [test]> ALTER TABLE us23a3719e74 DROP KEY dia34a99d3bc; Query OK, 0 rows affected (0.04 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [test]> SELECT COUNT(1) FROM sceb205fa121 sch WHERE EXISTS (SELECT 1 FROM ed8ec6a6b8d1 WHERE dia34a99d3bc = sch.dia34a99d3bc AND moc979966566 = 4 AND ye91b4a70018 = 34 ) AND EXISTS (SELECT 1 FROM us23a3719e74 usr INNER JOIN di569c818b1e dis ON usr.dia34a99d3bc = dis.idb80bb77402 WHERE usr.st9ed39e2ea9 = 0 AND usr.dia34a99d3bc = sch.dia34a99d3bc AND usr.ty94757cae63 IN (3, 4, 5)); +----------+ | COUNT(1) | +----------+ | 468 | +----------+ 1 row in set (0.10 sec) MariaDB [test]> ALTER TABLE us23a3719e74 ADD KEY (dia34a99d3bc); Query OK, 0 rows affected (0.24 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [test]> SELECT COUNT(1) FROM sceb205fa121 sch WHERE EXISTS (SELECT 1 FROM ed8ec6a6b8d1 WHERE dia34a99d3bc = sch.dia34a99d3bc AND moc979966566 = 4 AND ye91b4a70018 = 34 ) AND EXISTS (SELECT 1 FROM us23a3719e74 usr INNER JOIN di569c818b1e dis ON usr.dia34a99d3bc = dis.idb80bb77402 WHERE usr.st9ed39e2ea9 = 0 AND usr.dia34a99d3bc = sch.dia34a99d3bc AND usr.ty94757cae63 IN (3, 4, 5)); +----------+ | COUNT(1) | +----------+ | 2010407 | +----------+ 1 row in set (0.64 sec) MariaDB [test]>