- Same query, same system, different execution time
- SELECT
- f.form_question_has_answer_id
- FROM
- form_question_has_answer f
- INNER JOIN
- project_company_has_user p ON f.form_question_has_answer_user_id = p.project_company_has_user_user_id
- INNER JOIN
- company c ON p.project_company_has_user_company_id = c.company_id
- INNER JOIN
- project p2 ON p.project_company_has_user_project_id = p2.project_id
- INNER JOIN
- user u ON p.project_company_has_user_user_id = u.user_id
- INNER JOIN
- form f2 ON p.project_company_has_user_project_id = f2.form_project_id
- WHERE
- (f2.form_template_name = 'custom' AND p.project_company_has_user_garbage_collection = 0 AND p.project_company_has_user_project_id = '29') AND (LCASE(c.company_country) LIKE '%ge%' OR LCASE(c.company_country) LIKE '%abcde%') AND f.form_question_has_answer_form_id = '174'
- +----+-------------+-------+--------+----------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+----------------------------------------------------+------+-------------+
- | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
- +----+-------------+-------+--------+----------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+----------------------------------------------------+------+-------------+
- | 1 | SIMPLE | p2 | const | PRIMARY | PRIMARY | 4 | const | 1 | Using index |
- | 1 | SIMPLE | f | ref | form_question_has_answer_form_id,form_question_has_answer_user_id | form_question_has_answer_form_id | 4 | const | 796 | Using where |
- | 1 | SIMPLE | u | eq_ref | PRIMARY | PRIMARY | 4 | new_klarents.f.form_question_has_answer_user_id | 1 | Using index |
- | 1 | SIMPLE | p | ref | project_company_has_user_unique_key,project_company_has_user_user_id,project_company_has_user_company_id,project_company_has_user_project_id | project_company_has_user_user_id | 4 | new_klarents.f.form_question_has_answer_user_id | 1 | Using where |
- | 1 | SIMPLE | f2 | ref | form_project_id | form_project_id | 4 | const | 15 | Using where |
- | 1 | SIMPLE | c | eq_ref | PRIMARY | PRIMARY | 4 | new_klarents.p.project_company_has_user_company_id | 1 | Using where |
- +----+-------------+-------+--------+----------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+----------------------------------------------------+------+-------------+
- SELECT
- COUNT(*) AS num_results
- FROM (SELECT
- f.form_question_has_answer_id
- FROM
- form_question_has_answer f
- INNER JOIN
- project_company_has_user p ON f.form_question_has_answer_user_id = p.project_company_has_user_user_id
- INNER JOIN
- company c ON p.project_company_has_user_company_id = c.company_id
- INNER JOIN
- project p2 ON p.project_company_has_user_project_id = p2.project_id
- INNER JOIN
- user u ON p.project_company_has_user_user_id = u.user_id
- INNER JOIN
- form f2 ON p.project_company_has_user_project_id = f2.form_project_id
- WHERE
- (f2.form_template_name = 'custom' AND p.project_company_has_user_garbage_collection = 0 AND p.project_company_has_user_project_id = '29') AND (LCASE(c.company_country) LIKE '%ge%' OR LCASE(c.company_country) LIKE '%abcde%') AND f.form_question_has_answer_form_id = '174'
- GROUP BY
- f.form_question_has_answer_id;) dctrn_count_query;
- +----+-------------+-------+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+----------------------------------------------------+------+------------------------------+
- | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
- +----+-------------+-------+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+----------------------------------------------------+------+------------------------------+
- | 1 | PRIMARY | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Select tables optimized away |
- | 2 | DERIVED | p2 | const | PRIMARY | PRIMARY | 4 | | 1 | Using index |
- | 2 | DERIVED | f | ref | form_question_has_answer_form_id,form_question_has_answer_user_id | form_question_has_answer_form_id | 4 | | 797 | Using where |
- | 2 | DERIVED | p | ref | project_company_has_user_unique_key,project_company_has_user_user_id,project_company_has_user_company_id,project_company_has_user_project_id,project_company_has_user_garbage_collection | project_company_has_user_user_id | 4 | new_klarents.f.form_question_has_answer_user_id | 1 | Using where |
- | 2 | DERIVED | f2 | ref | form_project_id | form_project_id | 4 | | 15 | Using where |
- | 2 | DERIVED | c | eq_ref | PRIMARY | PRIMARY | 4 | new_klarents.p.project_company_has_user_company_id | 1 | Using where |
- | 2 | DERIVED | u | eq_ref | PRIMARY | PRIMARY | 4 | new_klarents.p.project_company_has_user_user_id | 1 | Using where; Using index |
- +----+-------------+-------+--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+----------------------------------------------------+------+------------------------------+
- +-------------+
- | num_results |
- +-------------+
- | 3 |
- +-------------+
- 1 row in set (2 min 14.28 sec)
- +--------------------------------+------------+
- | Status | Duration |
- +--------------------------------+------------+
- | starting | 0.000016 |
- | checking query cache for query | 0.000057 |
- | Opening tables | 0.004388 |
- | System lock | 0.000003 |
- | Table lock | 0.000036 |
- | init | 0.000030 |
- | optimizing | 0.000016 |
- | statistics | 0.000111 |
- | preparing | 0.000022 |
- | executing | 0.000004 |
- | Sorting result | 0.000002 |
- | Sending data | 136.213836 |
- | end | 0.000007 |
- | query end | 0.000002 |
- | freeing items | 0.004273 |
- | storing result in query cache | 0.000010 |
- | logging slow query | 0.000001 |
- | logging slow query | 0.000002 |
- | cleaning up | 0.000002 |
- +--------------------------------+------------+
- top - 15:43:25 up 78 days, 12:11, 4 users, load average: 1.42, 0.99, 0.78
- Tasks: 162 total, 2 running, 160 sleeping, 0 stopped, 0 zombie
- Cpu(s): 0.1%us, 50.4%sy, 0.0%ni, 49.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
- Mem: 4037868k total, 3772580k used, 265288k free, 243704k buffers
- Swap: 3905528k total, 265384k used, 3640144k free, 1207944k cached
- top - 15:44:31 up 78 days, 12:13, 4 users, load average: 1.94, 1.23, 0.87
- Tasks: 160 total, 2 running, 157 sleeping, 0 stopped, 1 zombie
- Cpu(s): 0.2%us, 50.6%sy, 0.0%ni, 49.3%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
- Mem: 4037868k total, 3834300k used, 203568k free, 243736k buffers
- Swap: 3905528k total, 265384k used, 3640144k free, 1207804k cached
- top - 11:04:58 up 79 days, 7:33, 4 users, load average: 0.39, 0.58, 0.76
- Tasks: 156 total, 1 running, 155 sleeping, 0 stopped, 0 zombie
- Cpu(s): 3.3%us, 2.8%sy, 0.0%ni, 93.9%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
- Mem: 4037868k total, 3676136k used, 361732k free, 271480k buffers
- Swap: 3905528k total, 268736k used, 3636792k free, 1063432k cached
- top - 15:47:07 up 110 days, 22:11, 7 users, load average: 0.17, 0.07, 0.06
- Tasks: 210 total, 2 running, 208 sleeping, 0 stopped, 0 zombie
- Cpu(s): 0.1%us, 0.2%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
- Mem: 4111972k total, 1821100k used, 2290872k free, 238860k buffers
- Swap: 4183036k total, 66472k used, 4116564k free, 921072k cached
- DESCRIBE SELECT
- COUNT(*) AS num_results
- FROM (SELECT
- f.form_question_has_answer_id
- FROM
- form_question_has_answer f
- INNER JOIN
- project_company_has_user p ON f.form_question_has_answer_user_id = p.project_company_has_user_user_id
- INNER JOIN
- company c ON p.project_company_has_user_company_id = c.company_id
- INNER JOIN
- project p2 ON p.project_company_has_user_project_id = p2.project_id
- INNER JOIN
- user u ON p.project_company_has_user_user_id = u.user_id
- INNER JOIN
- form f2 ON p.project_company_has_user_project_id = f2.form_project_id
- WHERE
- (f2.form_template_name = 'custom' AND p.project_company_has_user_garbage_collection = 0 AND p.project_company_has_user_project_id = '29') AND (LCASE(c.company_country) LIKE '%finland%' OR LCASE(c.company_country) LIKE '%finnland%') AND f.form_question_has_answer_form_id = '174'
- GROUP BY
- f.form_question_has_answer_id;) dctrn_count_query;