# Query run slower after no access for couple of hours or days, CHECK TABLE will help, but why?

**URL:** <https://forums.percona.com/t/query-run-slower-after-no-access-for-couple-of-hours-or-days-check-table-will-help-but-why/549>\
**Category:** Other MySQL® Questions\
**Created:** [November 30, 2007, 12:22pm UTC](https://forums.percona.com/t/query-run-slower-after-no-access-for-couple-of-hours-or-days-check-table-will-help-but-why/549 "2007-11-30T12:22:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aman](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@aman](https://forums.percona.com/u/aman)\
**Post date:** [November 30, 2007, 12:22pm UTC](https://forums.percona.com/t/query-run-slower-after-no-access-for-couple-of-hours-or-days-check-table-will-help-but-why/549/1 "2007-11-30T12:22:15Z")

</div>

Hello,

I have a query join a couple of tables, the biggest one of which has 12 million rows and an index that will be used in the query. The query uses group by and order by and speed is optimized to 150ms normally. However, If no query sent in couples of hours or days, the query may slow down to 30 seconds. If I run CHECK TABLE to the biggest table, then the query will speed up to 150ms again. Does anybody know what happened?

Thank you very much,

Luise

---

<div class="post-metadata">

**Author:** ![scoundrel](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@scoundrel](https://forums.percona.com/u/scoundrel)\
**Post date:** [December 1, 2007, 1:52am UTC](https://forums.percona.com/t/query-run-slower-after-no-access-for-couple-of-hours-or-days-check-table-will-help-but-why/549/2 "2007-12-01T01:52:15Z")

</div>

No queries for a couple of days is almost always = all data has been washed out of OS and mysql caches. Check table statement reads an entire table and fills OS buffers again. So consequitive queries would be fast.

---

<div class="post-metadata">

**Author:** ![aman](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@aman](https://forums.percona.com/u/aman)\
**Post date:** [December 3, 2007, 1:40pm UTC](https://forums.percona.com/t/query-run-slower-after-no-access-for-couple-of-hours-or-days-check-table-will-help-but-why/549/3 "2007-12-03T13:40:47Z")

</div>

Thank you so much for your reply. It’s same as what I guess. That helps me a lot definitely.

---

<div class="post-metadata">

**Author:** ![aman](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@aman](https://forums.percona.com/u/aman)\
**Post date:** [December 3, 2007, 1:48pm UTC](https://forums.percona.com/t/query-run-slower-after-no-access-for-couple-of-hours-or-days-check-table-will-help-but-why/549/4 "2007-12-03T13:48:52Z")

</div>

Sorry, I still have a question, the first query will take about 30sec, and the subsequent queries will take about 10sec. Actually, this server is a development server, so nobody will touch it except me. It only can be accelerated to 150ms level until I run CHECK TABLE. Is there something else behind the scene?

Thank you so much

---

<div class="post-metadata">

**Author:** ![scoundrel](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@scoundrel](https://forums.percona.com/u/scoundrel)\
**Post date:** [December 3, 2007, 3:18pm UTC](https://forums.percona.com/t/query-run-slower-after-no-access-for-couple-of-hours-or-days-check-table-will-help-but-why/549/5 "2007-12-03T15:18:51Z")

</div>

Post your query (SELECT…) here along with “ANALYZE SELECT…” query results and we’ll try to help. Even 150ms is way too much for a query on development machine (machine with a small dataset).
