Note that there are some explanatory texts on larger screens.

plurals
  1. POtoo much time to execute
    primarykey
    data
    text
    <ol> <li>Below query is taking long time to execute around 2mins please help me how to improve performance of this query.</li> <li>so our requirement is to get result within 2 to 3secs.</li> <li>query is using indexes also.</li> <li>but it was performing more scan.</li> </ol> <p>query: </p> <pre><code>select max(`log_date`) from `top_competitor_summary_entity` where own_domain_id = 4 and keyword_top1_count &gt; 0 and (grouptag_id = 0 OR grouptag_id is null); </code></pre> <p>Expalin Plan:</p> <pre><code>+----+-------------+-------------------------------+------+--------------------------------------+------------------------+---------+-------+---------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------------------------------+------+--------------------------------------+------------------------+---------+-------+---------+-------------+ | 1 | SIMPLE | top_competitor_summary_entity | ref | own_domain_id,own_domain_id_log_date | own_domain_id_log_date | 4 | const | 2100128 | Using where | +----+-------------+-------------------------------+------+--------------------------------------+------------------------+---------+-------+---------+-------------+ 1 row in set (0.66 sec) </code></pre> <p>Table structure:</p> <pre><code>mysql&gt; show create table top_competitor_summary_entity\G *************************** 1. row *************************** Table: top_competitor_summary_entity Create Table: CREATE TABLE `top_competitor_summary_entity` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `domain` varchar(255) NOT NULL COMMENT 'competitor domain name', `own_domain_id` int(11) NOT NULL, `keyword_top10_count` int(11) DEFAULT NULL, `keyword_top3_count` int(11) DEFAULT NULL, `keyword_top1_count` int(11) DEFAULT NULL, `keyword_top10_search_volume` bigint(20) DEFAULT NULL, `keyword_top3_search_volume` bigint(20) DEFAULT NULL, `keyword_top1_search_volume` bigint(20) DEFAULT NULL, `url_top10_count` int(11) DEFAULT NULL COMMENT 'how many competitor url in Top 10', `log_date` date DEFAULT NULL, `grouptag_id` int(11) DEFAULT '0', `keyword_top10_count_bing` int(11) DEFAULT '0', `keyword_top10_count_yahoo` int(11) DEFAULT '0', `keyword_top3_count_bing` int(11) DEFAULT '0', `keyword_top3_count_yahoo` int(11) DEFAULT '0', `keyword_top1_count_bing` int(11) DEFAULT '0', `keyword_top1_count_yahoo` int(11) DEFAULT '0', PRIMARY KEY (`id`), KEY `own_domain_id` (`own_domain_id`), KEY `domain_own_domain_id_log_date` (`domain`,`own_domain_id`,`log_date`), KEY `own_domain_id_log_date` (`own_domain_id`,`log_date`) ) ENGINE=InnoDB AUTO_INCREMENT=680592051 DEFAULT CHARSET=utf8 1 row in set (0.09 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.
 

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