# Very very slow queries!

**URL:** <https://forums.percona.com/t/very-very-slow-queries/4974>\
**Category:** Percona Server for MySQL 5.6\
**Created:** [July 17, 2016, 2:03pm UTC](https://forums.percona.com/t/very-very-slow-queries/4974 "2016-07-17T14:03:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luca\_Leen](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/luca_leen/32/1126_2.png) [@Luca\_Leen](https://forums.percona.com/u/Luca_Leen)\
**Post date:** [July 17, 2016, 2:03pm UTC](https://forums.percona.com/t/very-very-slow-queries/4974/1 "2016-07-17T14:03:42Z")

</div>

Hi to all, I’m trying a percona xtradb cluster (3 nodes) on a rancher environment (automatically created from rancher catalog).

Replication works great, but I’ve lots of problems with slow queries.

First of all, for exclude network problems etc, I’m executing the query directly inside the node container.

The query is simple, and this is the result:

[HTML]mysql\> SELECT SQL\_NO\_CACHE SUM(A.price) as sales  
 → FROM appointments A  
 → WHERE A.venue\_id = 24  
 → AND A.treatment\_id IN (2,3,14,26,43,46,66,77,84,100,101,114,115,144,161,1  
62,163,164,192,193,194,209,211,267,322)  
 → AND (DATE(A.time) \>= ‘2016-05-01’ AND DATE(A.time) \<= ‘2016-05-31’)  
 → AND A.STATE IN (‘booked’,‘checked\_in’,‘checked\_out’,‘archived’);  
±------+  
| sales |  
±------+  
| 11975 |  
±------+

1 row in set (34.88 sec)  
[/HTML]

I created a simple mysql container on the same server, without custom configurations. I imported the same DB, and executed the same query:

[HTML]mysql\> SELECT SQL\_NO\_CACHE SUM(A.price) as sales  
 → FROM appointments A  
 → WHERE A.venue\_id = 24  
 → AND A.treatment\_id IN (2,3,14,26,43,46,66,77,84,100,101,114,115,144,161,1  
62,163,164,192,193,194,209,211,267,322)  
 → AND (DATE(A.time) \>= ‘2016-05-01’ AND DATE(A.time) \<= ‘2016-05-31’)  
 → AND A.STATE IN (‘booked’,‘checked\_in’,‘checked\_out’,‘archived’);  
±------+  
| sales |  
±------+  
| 11975 |  
±------+  
1 row in set (0.02 sec)  
[/HTML]

Same server, same DB, no custom configurations… so… What can be the problem?

I hope that somebody can help me.

Thanks!

PS: I’m using version 5.6.28 (no other versions are available in rancher)

PXC SERVER:

[HTML]±—±------------±------±------±-----------------------------------------±-------------±--------±-----±------±-----------------------------------+  
| id | select\_type | table | type | possible\_keys |key | key\_len | ref | rows | Extra |  
±—±------------±------±------±-----------------------------------------±-------------±--------±-----±------±-----------------------------------+  
| 1 | SIMPLE | A | range | venue\_id,state,treatment\_id,multi\_column |treatment\_id | 4 | NULL | 15900 | Using index condition; Using where |  
±—±------------±------±------±-----------------------------------------±-------------±--------±-----±------±-----------------------------------+  
1 row in set (0.00 sec)[/HTML]  
MYSQL:

[HTML]±—±------------±------±-----------±------±-----------------------------------------±-------------±--------±-----±-------±---------±---------------------------------+  
| id | select\_type | table | partitions | type | possible\_keys | key | key\_len | ref | rows | filtered | Extra |  
±—±------------±------±-----------±------±-----------------------------------------±-------------±--------±-----±-------±---------±---------------------------------+  
| 1 | SIMPLE | A | NULL | range | venue\_id,state,treatment\_id,multi\_column | multi\_column | 26 | NULL | 107113 | 65.10 | Using index condition; Using MRR |  
±—±------------±------±-----------±------±-----------------------------------------±-------------±--------±-----±-------±---------±---------------------------------+  
1 row in set, 1 warning (0.01 sec)[/HTML]  
Versions:

[HTML]PXC: 5.6.28-76.1-56  
MYSQL: 5.7.12[/HTML]

Indexes (same for both):

[HTML]±-------------±-----------±---------------------------±-------------±---------------------------±----------±------------±---------±-------±-----±-----------±--------±--------------+  
| Table | Non\_unique | Key\_name | Seq\_in\_index | Column\_name | Collation | Cardinality | Sub\_part | Packed | Null | Index\_type | Comment | Index\_comment |  
±-------------±-----------±---------------------------±-------------±---------------------------±----------±------------±---------±-------±-----±-----------±--------±--------------+  
| appointments | 0 | id | 1 | id | A | 3120188 | NULL | NULL | | BTREE | | |  
| appointments | 1 | venue\_id | 1 | venue\_id | A | 368 | NULL | NULL | | BTREE | | |  
| appointments | 1 | state | 1 | state | A | 8 | NULL | NULL | | BTREE | | |  
| appointments | 1 | time | 1 | time | A | 45835 | NULL | NULL | | BTREE | | |  
| appointments | 1 | treatment\_id | 1 | treatment\_id | A | 2081 | NULL | NULL | | BTREE | | |  
| appointments | 1 | staff\_member\_id | 1 | staff\_member\_id | A | 2516 | NULL | NULL | | BTREE | | |  
| appointments | 1 | customer\_id | 1 | customer\_id | A | 421915 | NULL | NULL | | BTREE | | |  
| appointments | 1 | multi\_column | 1 | venue\_id | A | 320 | NULL | NULL | | BTREE | | |  
| appointments | 1 | multi\_column | 2 | state | A | 2248 | NULL | NULL | | BTREE | | |  
| appointments | 1 | multi\_column | 3 | time | A | 2158187 | NULL | NULL | | BTREE | | |  
| appointments | 1 | multi\_column | 4 | treatment\_id | A | 2713420 | NULL | NULL | | BTREE | | |  
±-------------±-----------±---------------------------±-------------±---------------------------±----------±------------±---------±-------±-----±-----------±--------±--------------+[/HTML]

EDIT2:

[HTML]mysql\> SELECT SQL\_NO\_CACHE SUM(A.price) as sales  
 → FROM appointments A FORCE INDEX(multi\_column)  
 → WHERE A.venue\_id = 24  
 → AND A.treatment\_id IN (2,3,14,26,43,46,66,77,84,100,101,114,115,144,161,1  
62,163,164,192,193,194,209,211,267,322)  
 → AND (DATE(A.time) \>= ‘2016-05-01’ AND DATE(A.time) \<= ‘2016-05-31’)  
 → AND A.STATE IN (‘booked’,‘checked\_in’,‘checked\_out’,‘archived’);  
±------+  
| sales |  
±------+  
| 11975 |  
±------+  
1 row in set (0.04 sec)[/HTML]
