# Need some help with select datetime range performance

**URL:** <https://forums.percona.com/t/need-some-help-with-select-datetime-range-performance/885>\
**Category:** Other MySQL® Questions\
**Created:** [August 13, 2008, 11:35pm UTC](https://forums.percona.com/t/need-some-help-with-select-datetime-range-performance/885 "2008-08-13T23:35:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fjork\_duf](https://avatars.discourse-cdn.com/v4/letter/f/aca169/32.png) [@fjork\_duf](https://forums.percona.com/u/fjork_duf)\
**Post date:** [August 13, 2008, 11:35pm UTC](https://forums.percona.com/t/need-some-help-with-select-datetime-range-performance/885/1 "2008-08-13T23:35:19Z")

</div>

I have a db at work a colleague created. I don’t have the ability to change the schema, but I could make a case for it if there is an opportunity for some speed improvements.

The app I have has some results in it that have dates. So when I get the results I do a select that looks something like this:

select time, text from results  
where  
results.error\_level\_id = 100 and  
results.log\_source\_id = 200 and  
time \>= ‘2008-08-13 15:00’ and  
time \<= ‘2008-08-14 15:00’

I wouldn’t think that it would but this query takes about 136s according to the MySQL query browser. Even when the result is an empty set.

So I have a few questions:

Why does it take so long?  
How can I make it faster?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![vgatto](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/vgatto/32/748_2.png) [@vgatto](https://forums.percona.com/u/vgatto)\
**Post date:** [August 15, 2008, 12:00pm UTC](https://forums.percona.com/t/need-some-help-with-select-datetime-range-performance/885/2 "2008-08-15T12:00:46Z")

</div>

I recommend gathering the following information:

1. The EXPLAIN plan for your query
2. SHOW TABLE STATUS LIKE ‘results’
3. SHOW INDEXES FROM results

After that, someone here might have a suggestion.
