# long\_query\_time not working

**URL:** <https://forums.percona.com/t/long-query-time-not-working/3803>\
**Category:** Other MySQL® Questions\
**Created:** [October 6, 2014, 6:31pm UTC](https://forums.percona.com/t/long-query-time-not-working/3803 "2014-10-06T18:31:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chavasree](https://avatars.discourse-cdn.com/v4/letter/c/5f8ce5/32.png) [@chavasree](https://forums.percona.com/u/chavasree)\
**Post date:** [October 6, 2014, 6:31pm UTC](https://forums.percona.com/t/long-query-time-not-working/3803/1 "2014-10-06T18:31:19Z")

</div>

I changed this variable long\_query\_time=10 during runtime and unable to see any difference as the slow query log is logging each and every query and filling up the disk space. i ran the below command but of no use.

set GLOBAL long\_query\_time=10;

but i don’t see any change…i still see queries with querytime=0.0000012 are still writing to slow\_query log file.

i disabled slow query log and it stops writing to slow query log… but once i enable it again with long\_query\_time=10 i still see queries with 0 secs logging into it… and my settings are below.

mysql\> show variables like ‘%slow%’;  
±--------------------------±---------------------------------+  
| Variable\_name | Value |  
±--------------------------±---------------------------------+  
| log\_slow\_admin\_statements | OFF |  
| log\_slow\_slave\_statements | OFF |  
| slow\_launch\_time | 2 |  
| slow\_query\_log | OFF |  
| slow\_query\_log\_file | /data/logs/slow/slow-queries.log |  
±--------------------------±---------------------------------+

±-------------------------------------------------------±----------+  
| Variable\_name | Value |  
±-------------------------------------------------------±----------+  
| long\_query\_time | 10.000000 |

Please help.

Thanks,

---

<div class="post-metadata">

**Author:** ![scott.nemes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/scott.nemes/32/5_2.png) [@scott.nemes](https://forums.percona.com/u/scott.nemes)\
**Post date:** [October 6, 2014, 6:49pm UTC](https://forums.percona.com/t/long-query-time-not-working/3803/2 "2014-10-06T18:49:26Z")

</div>

Hi chavasree;

This could be a few things:

1. If you are using a version of Percona Server older than 5.5.37, then it could be this bug:  
[url][https://bugs.launchpad.net/percona-server/+bug/1016991[/url]](https://bugs.launchpad.net/percona-server/+bug/1016991%5B/url%5D)

2. It could be that you have log\_queries\_not\_using\_indexes enabled, which would cause queries quicker than 10 seconds to be logged if they are not using an index.

3. It could also be the fact that changing the long\_query\_time only affects new connections, so if you have connections that remain open for long periods of time, they may not be picking up the new setting.

-Scott

---

<div class="post-metadata">

**Author:** ![chavasree](https://avatars.discourse-cdn.com/v4/letter/c/5f8ce5/32.png) [@chavasree](https://forums.percona.com/u/chavasree)\
**Post date:** [October 6, 2014, 10:56pm UTC](https://forums.percona.com/t/long-query-time-not-working/3803/3 "2014-10-06T22:56:40Z")

</div>

here are my answers… i am using latest version of mysql

MySql Version: 5.6.19

and this is the current setting of the variable.

log\_queries\_not\_using\_indexes =0

1. It could also be the fact that changing the long\_query\_time only affects new connections, so if you have connections that remain open for long periods of time, they may not be picking up the new setting.

Yes you might be right, i have some connections already open and the current setting doesn’t apply to it, even though i tried using flush hosts, flush logs… nothing worked for me, looks like i need to kill those connections and let the app re-connect it…

what do you say.

thanks,  
Sree

---

<div class="post-metadata">

**Author:** ![scott.nemes](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/scott.nemes/32/5_2.png) [@scott.nemes](https://forums.percona.com/u/scott.nemes)\
**Post date:** [October 7, 2014, 9:46am UTC](https://forums.percona.com/t/long-query-time-not-working/3803/4 "2014-10-07T09:46:04Z")

</div>

Hi chavasree;

Yeah you would need your app to reconnect one way or another. The brute force way of killing the threads would work assuming your app auto-connects, but just be careful that your app can handle it gracefully, especially if this is a production database. =)

-Scott

---

<div class="post-metadata">

**Author:** ![Robert\_Guy](https://avatars.discourse-cdn.com/v4/letter/r/d07c76/32.png) [@Robert\_Guy](https://forums.percona.com/u/Robert_Guy)\
**Post date:** [November 4, 2014, 8:51pm UTC](https://forums.percona.com/t/long-query-time-not-working/3803/5 "2014-11-04T20:51:21Z")

</div>

Thanks so much chavasree.

> [@](#):
>
> log\_queries\_not\_using\_indexes =0

Worked great! Saved a lot of time.

Regards,  
[Robert](http://www.laowai.gotgeeks.com)

The Guy from Beijing.
