Note that there are some explanatory texts on larger screens.

plurals
  1. POSlow MySQL Query
    primarykey
    data
    text
    <p>The following SQL query takes approximately <strong>1 min. 15 sec.</strong> to execute when entered directly into the SQL console. There are <strong>6636 records in the qv_attribute table</strong>.</p> <p>Is the execution time for this query normal? Is there any way to reduce the time it takes to run this operation by changing database settings or optimizing the query?</p> <pre><code>SELECT a.node_id, MAX(CASE WHEN(b.att_id = 9003) THEN a.att_description END) AS 'ICS_Owner', MAX(CASE WHEN(b.att_id = 9004) THEN a.att_description END) AS 'Service', MAX(CASE WHEN(t.rel_id = 12092) THEN t.att_description END) AS 'Contact_Name', MAX(CASE WHEN(t.rel_id = 12610) THEN t.att_description END) AS 'Address_1', MAX(CASE WHEN(t.rel_id = 9007) THEN t.att_description END) AS 'Address_2', MAX(CASE WHEN(t.rel_id = 12612) THEN t.att_description END) AS 'City', MAX(CASE WHEN(t.rel_id = 12614) THEN t.att_description END) AS 'State', MAX(CASE WHEN(t.rel_id = 13508) THEN t.att_description END) AS 'a', MAX(CASE WHEN(t.rel_id = 13509) THEN t.att_description END) AS 'b', MAX(CASE WHEN(b.att_id = 13132) THEN a.att_description END) AS 'Description', MAX(CASE WHEN(des.node_id = 10824) THEN des.att_description END) AS 'Row_Description' FROM `qv_attribute` t, `qv_attribute` a, `qv_attribute` b, `qv_attribute` des WHERE b.att_id IN (9003,9004,13132,14542) AND b.att_name = a.att_name AND ((a.node_id = 1554 AND ((t.node_id = 1776 AND des.att_order = 1) OR (t.node_id = 1780 AND des.att_order = 2) OR (t.node_id = 1781 AND des.att_order = 3) OR (t.node_id = 1782 AND des.att_order = 4) OR (t.node_id = 1783 AND des.att_order = 5) OR (t.node_id = 1784 AND des.att_order = 6) OR (t.node_id = 1778 AND des.att_order = 7) OR (t.node_id = 1777 AND des.att_order = 8))) OR (a.node_id = 1574 AND ((t.node_id = 1574 AND des.att_order = 1) OR (t.node_id = 1779 AND des.att_order = 2) OR (t.node_id = 1576 AND des.att_order = 3) OR (t.node_id = 1577 AND des.att_order = 4) OR (t.node_id = 1710 AND des.att_order = 5) OR (t.node_id = 1711 AND des.att_order = 6) OR (t.node_id = 1712 AND des.att_order = 7))) OR (a.node_id = 1803 AND ((t.node_id = 1838 AND des.att_order = 1) OR (t.node_id = 1839 AND des.att_order = 2) OR (t.node_id = 1840 AND des.att_order = 3) OR (t.node_id = 1805 AND des.att_order = 4))) OR (a.node_id = 1831 AND ((t.node_id = 1842 AND des.att_order = 1) OR (t.node_id = 1847 AND des.att_order = 2) OR (t.node_id = 1833 AND des.att_order = 3) OR (t.node_id = 1848 AND des.att_order = 4) OR (t.node_id = 1845 AND des.att_order = 5) OR (t.node_id = 1846 AND des.att_order = 6) OR (t.node_id = 1841 AND des.att_order = 7) OR (t.node_id = 1844 AND des.att_order = 8) OR (t.node_id = 1843 AND des.att_order = 9))) OR (a.node_id = 1810 AND ((t.node_id = 1854 AND des.att_order = 1) OR (t.node_id = 1849 AND des.att_order = 2) OR (t.node_id = 1851 AND des.att_order = 3) OR (t.node_id = 1853 AND des.att_order = 4) OR (t.node_id = 1852 AND des.att_order = 5) OR (t.node_id = 1812 AND des.att_order = 6) OR (t.node_id = 1850 AND des.att_order = 7)))) GROUP BY a.node_id, t.node_id </code></pre> <p>EXPLAIN EXTENDED:</p> <pre><code>+----+-------------+-------+-------+---------------+---------+---------+------+------+----------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+---------------+---------+---------+------+------+----------------------------------------------+ | 1 | SIMPLE | b | range | PRIMARY | PRIMARY | 4 | NULL | 4 | Using where; Using temporary; Using filesort | | 1 | SIMPLE | des | ALL | NULL | NULL | NULL | NULL | 6695 | Using where | | 1 | SIMPLE | t | range | node_id | node_id | 4 | NULL | 629 | Using where | | 1 | SIMPLE | a | range | node_id | node_id | 4 | NULL | 139 | Using where | +----+-------------+-------+-------+---------------+---------+---------+------+------+----------------------------------------------+ 4 rows in set, 1 warning (0.00 sec) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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