# how optimize this query?

**URL:** <https://forums.percona.com/t/how-optimize-this-query/643>\
**Category:** Other MySQL® Questions\
**Created:** [February 18, 2008, 6:02am UTC](https://forums.percona.com/t/how-optimize-this-query/643 "2008-02-18T06:02:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![buxmac](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@buxmac](https://forums.percona.com/u/buxmac)\
**Post date:** [February 18, 2008, 6:02am UTC](https://forums.percona.com/t/how-optimize-this-query/643/1 "2008-02-18T06:02:46Z")

</div>

My table has 70 columns… too many I know… anyway I need to optimize this slow query:

EXPLAIN SELECT COUNT(\*) FROM MY\_ORDER WHERE MY\_DATE\>=DATE\_SUB(CURDATE(), interval 15 day) AND MY\_STATUS != ‘5’ AND MY\_STATUS != ‘10’ AND MY\_PHONE=‘14112319’ ID SELECT\_TYPE TABLE TYPE POSSIBLE\_KEYS KEY KEY\_LEN REF ROWS EXTRA1 SIMPLE MY\_ORDER range MY\_DATE,MY\_STATUS MY\_STATUS 4 \N 737002 Using where

Do you have any idea?

Thank you!

---

<div class="post-metadata">

**Author:** ![jonstjohn](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jonstjohn](https://forums.percona.com/u/jonstjohn)\
**Post date:** [February 23, 2008, 9:54am UTC](https://forums.percona.com/t/how-optimize-this-query/643/2 "2008-02-23T09:54:13Z")

</div>

You could create an index that covers all of the criteria. That index could be:

create index new\_index(MY\_STATUS, MY\_PHONE, MY\_DATE);

That order might work well, although you could play around with different orders for the multi-column index. Trial and error!
