Note that there are some explanatory texts on larger screens.

plurals
  1. POlong running query
    primarykey
    data
    text
    <p>1.Below query is taking around 49 sec to execute. 2.our target is need to get result in 1 to 2sec. 3.query having indexes and it was using 4.how to avoide this long time execution. 5.it is a simple query 6.if possible help me to rewrite the query.</p> <pre><code>query: select cppm.* from cat_ctlg_product_product_map cppm, cat_product_product_map ppm where cppm.product_product_map_id = ppm.product_product_map_id and ppm.product_id = 2585682 and cppm.catalog_id in ( 2136359, 2136371); Explain plan: +----+-------------+-------+-------+------------------------------------+---------------------------+---------+-------+--------+--------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+------------------------------------+---------------------------+---------+-------+--------+--------------------------------+ | 1 | SIMPLE | ppm | ref | PRIMARY,idx_3342,idx_5419 | idx_3342 | 4 | const | 1 | Using index | | 1 | SIMPLE | cppm | range | idx_3472,fkey_cat_ctlg_produc_4100 | fkey_cat_ctlg_produc_4100 | 4 | NULL | 135334 | Using where; Using join buffer | +----+-------------+-------+-------+------------------------------------+---------------------------+---------+-------+--------+--------------------------------+ 2 rows in set (0.00 sec) Table structures: mysql&gt; show create table cat_ctlg_product_product_map\G *************************** 1. row *************************** Table: cat_ctlg_product_product_map Create Table: CREATE TABLE `cat_ctlg_product_product_map` ( `row_mod` datetime DEFAULT NULL, `row_create` datetime DEFAULT NULL, `product_product_map_id` int(11) NOT NULL, `catalog_id` int(11) NOT NULL, UNIQUE KEY `idx_3472` (`product_product_map_id`,`catalog_id`), KEY `fkey_cat_ctlg_produc_4100` (`catalog_id`), CONSTRAINT `fkey_cat_ctlg_produc_4100` FOREIGN KEY (`catalog_id`) REFERENCES `cat_catalogs` (`catalog_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fkey_cat_ctlg_produc_5415` FOREIGN KEY (`product_product_map_id`) REFERENCES `cat_product_product_map` (`product_product_map_id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin 1 row in set (0.00 sec) mysql&gt; show create table cat_product_product_map\G *************************** 1. row *************************** Table: cat_product_product_map Create Table: CREATE TABLE `cat_product_product_map` ( `row_mod` datetime DEFAULT NULL, `row_create` datetime DEFAULT NULL, `product_product_map_id` int(11) NOT NULL, `owner_catalog_id` int(11) NOT NULL, `parent_product_id` int(11) NOT NULL, `product_id` int(11) NOT NULL, `precedence` int(11) DEFAULT '100', `is_default` int(11) DEFAULT NULL, `product_product_type` enum('cross-sell','skuoption','up-sell','addon','works','kit','autocross') COLLATE latin1_bin DEFAULT NULL, PRIMARY KEY (`product_product_map_id`), KEY `idx_3342` (`product_id`,`product_product_type`), KEY `idx_5251` (`parent_product_id`,`product_product_type`,`product_id`), KEY `idx_5419` (`product_product_map_id`,`parent_product_id`,`product_id`), KEY `fkey_cat_product_pro_4229` (`owner_catalog_id`), KEY `cat_product_product_map_n1` (`parent_product_id`,`product_product_type`,`product_product_map_id`,`precedence`), CONSTRAINT `fkey_cat_product_pro_3617` FOREIGN KEY (`product_id`) REFERENCES `cat_products` (`product_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fkey_cat_product_pro_4229` FOREIGN KEY (`owner_catalog_id`) REFERENCES `cat_catalogs` (`catalog_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fkey_cat_product_pro_4362` FOREIGN KEY (`parent_product_id`) REFERENCES `cat_products` (`product_id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin 1 row in set (0.00 sec) </code></pre>
    singulars
    1. This table or related slice is empty.
    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