Structure of my table
mysql> show create table t_group_tag_relation\G
*************************** 1. row ***************************
Table: t_group_tag_relation
Create Table: CREATE TABLE
t_group_tag_relation
(
id
int(11) NOT NULL AUTO_INCREMENT,
domain_id
int(11) NOT NULL,
group_tag_id
int(11) NOT NULL,
resource_id
int(11) NOT NULL,
resource_type
int(11) DEFAULT NULL,
PRIMARY KEY (id
),
UNIQUE KEY group_tag_id_resource_id
(group_tag_id
,resource_id
),
KEY domain_id
(domain_id
,group_tag_id
,resource_type
,resource_id
),
KEY domain_id_resource_type
(domain_id
,resource_type
)
) ENGINE=InnoDB AUTO_INCREMENT=1613462 DEFAULT CHARSET=latin1
1 row in set (0.03 sec)
Explain plan of my query
mysql> explain select * from t_group_tag_relation WHERE resource_id = 575868070 AND domain_id = 476 AND resource_type = 2;
+----+-------------+----------------------+------+-----------------------------------+-----------+---------+-------+-------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------------------+------+-----------------------------------+-----------+---------+-------+-------+--------------------------+
| 1 | SIMPLE | t_group_tag_relation | ref | domain_id,domain_id_resource_type | domain_id | 4 | const | 28400 | Using where; Using index |
+----+-------------+----------------------+------+-----------------------------------+-----------+---------+-------+-------+--------------------------+
1 row in set (0.57 sec)
It is using indexes already but performance is not good.
How to improve performance?
Asked by ashuthosh
(707 rep)
Dec 12, 2012, 09:02 AM
Last activity: Sep 7, 2021, 08:09 PM
Last activity: Sep 7, 2021, 08:09 PM