# Sleeping Queries

**URL:** <https://forums.percona.com/t/sleeping-queries/73>\
**Category:** Other MySQL® Questions\
**Created:** [August 30, 2006, 2:28pm UTC](https://forums.percona.com/t/sleeping-queries/73 "2006-08-30T14:28:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbazemore](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@sbazemore](https://forums.percona.com/u/sbazemore)\
**Post date:** [August 30, 2006, 2:28pm UTC](https://forums.percona.com/t/sleeping-queries/73/1 "2006-08-30T14:28:22Z")

</div>

Why would mysql not clear sleeping queries properly?

In order for our site to run, we have to set our wait\_timeout to 5 in to properly clear the connections or we reach our max connections in a matter of seconds.

If we set the wait\_timeout to the default of 28800, most of the sleeping connections never clear out until they hit that limit which causes the connection count to max out constantly.

Any pointers would be highly appreciated.

Thanks

Stephen

---

<div class="post-metadata">

**Author:** ![Peter](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/peter/32/2_2.png) [@Peter](https://forums.percona.com/u/Peter)\
**Post date:** [August 30, 2006, 3:24pm UTC](https://forums.percona.com/t/sleeping-queries/73/2 "2006-08-30T15:24:57Z")

</div>

Hi,

What operation system are you using ? And what kind of language ?

Are you closing connection properly in your application by calling mysql\_close() ?

Typically if application does not close connection it is automatically closed when connection is aborted, ie process terminates.

In some cases however it may take a while for remote size to discover connection was aborted which may show up as sleeping connection for rather long time.

Also how does your processlist looks ?

---

<div class="post-metadata">

**Author:** ![sbazemore](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@sbazemore](https://forums.percona.com/u/sbazemore)\
**Post date:** [August 30, 2006, 3:32pm UTC](https://forums.percona.com/t/sleeping-queries/73/3 "2006-08-30T15:32:49Z")

</div>

We are running Windows Server 2003, MySQL 5.0.24, and PHP5. Also, I am explicitly closing the connection and the sleeps are still there.

The process list looks good with the exception of it being filled with sleeps from 1 second to 5 seconds, which is where they get killed by the wait\_timeout.
