Note that there are some explanatory texts on larger screens.

plurals
  1. POMySql: make this query faster… is there a way ? PART TWO
    text
    copied!<p>This is part two of the question: <a href="https://stackoverflow.com/questions/2913639/mysql-make-this-query-faster-theres-a-way">MySql: make this query faster... is there a way?</a></p> <p>this query still run slowly:</p> <pre><code>SELECT b.id, b.name, c.name FROM bookcorr as a JOIN books as b on b.id = a.books_id = JOIN Library as c on c.id = a.library_id WHERE a.category_id = '2521' AND a.library_id = '4983' ORDER BY b.name ASC LIMIT 0,15 </code></pre> <p>Any suggest ?</p> <pre><code>CREATE TABLE `bookcorr` ( `category_id` smallint(4) unsigned NOT NULL, `book_id` mediumint(7) unsigned NOT NULL, `library_id` smallint(5) unsigned NOT NULL, UNIQUE KEY `cat_id_3` (`category_id`,`book_id`,`library_id`), KEY `category_id` (`category_id`), KEY `book_id` (`book_id`), KEY `library_id` (`library_id`), KEY `cat_id_2` (`cat_id`,`com_id`)) CREATE TABLE `books` ( `id` mediumint(7) unsigned NOT NULL AUTO_INCREMENT, `com_id` smallint(5) unsigned NOT NULL, `name` varchar(256) NOT NULL, .... PRIMARY KEY (`id`), KEY `name` (`name`), FULLTEXT KEY `search` (`name`,`author`) ) CREATE TABLE `Library` ( `id` smallint(4) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(256) NOT NULL, ... UNIQUE KEY `id` (`id`), KEY `library_name` (`name`) ) CREATE TABLE `Category` ( `id` smallint(4) unsigned NOT NULL, `name` varchar(100) NOT NULL, UNIQUE KEY `id` (`id`), KEY `name` (`name`), ) </code></pre> <p>Here: </p> <pre><code>+----+-------------+-------+--------+----------------------------------------+----------+---------+----------------------------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+--------+----------------------------------------+----------+---------+----------------------------+------+-------------+ | 1 | SIMPLE | b | index | NULL | name | 258 | NULL | 15 | | | 1 | SIMPLE | a | eq_ref | cat_id_3,cat_id,book_id,library_id | cat_id_3 | 7 | const,b.id,const | 1 | Using index | | 1 | SIMPLE | c | const | PRIMARY | PRIMARY | 2 | const | 1 | Using where | +----+-------------+-------+--------+----------------------------------------+----------+---------+----------------------------+------+-------------+ </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload