# pmm table status  this query it's very slow, server has hang

**URL:** https://forums.percona.com/t/pmm-table-status-this-query-its-very-slow-server-has-hang/5172
**Category:** PMM 1.x
**Created:** [October 26, 2016, 8:53pm UTC](https://forums.percona.com/t/pmm-table-status-this-query-its-very-slow-server-has-hang/5172 "2016-10-26T20:53:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mmajaJoker](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mmajajoker/32/1143_2.png) [@mmajaJoker](https://forums.percona.com/u/mmajaJoker)
#### Post date: [October 26, 2016, 8:53pm UTC](https://forums.percona.com/t/pmm-table-status-this-query-its-very-slow-server-has-hang/5172/1 "2016-10-26T20:53:48Z")

</div>

SELECT table\_schema, table\_name, column\_name, auto\_increment, pow(2, case data\_type when ‘tinyint’ then 7 when ‘smallint’ then 15 when ‘mediumint’ then 23 when ‘int’ then 31 when ‘bigint’ then 63 end+(column\_type like ‘% unsigned’))-1 as max\_int FROM information\_schema.tables t JOIN information\_schema.columns c USING (table\_schema,table\_name) WHERE c.extra = ‘auto\_increment’ AND t.auto\_increment IS NOT NULL

---

<div class="post-metadata">

### Author: ![weber](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@weber](https://forums.percona.com/u/weber)
#### Post date: [October 27, 2016, 3:50am UTC](https://forums.percona.com/t/pmm-table-status-this-query-its-very-slow-server-has-hang/5172/2 "2016-10-27T03:50:28Z")

</div>

How many tables do you have? `select count(*) from information_schema.tables;`

To prevent such queries you need to disable tablestats. Normally, tablestats is automatically disabled on 1000+ tables (`pmm-admin list` will show this on OPTIONS column).

To disable tablestats explicitly, re-add “mysql:metrics” service using pmm-admin with --disabla-tablestats flag.

---

<div class="post-metadata">

### Author: ![mmajaJoker](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mmajajoker/32/1143_2.png) [@mmajaJoker](https://forums.percona.com/u/mmajaJoker)
#### Post date: [October 27, 2016, 8:13pm UTC](https://forums.percona.com/t/pmm-table-status-this-query-its-very-slow-server-has-hang/5172/3 "2016-10-27T20:13:11Z")

</div>

> [@weber;46279](#):
>
> How many tables do you have? `select count(*) from information_schema.tables;`
> 
> To prevent such queries you need to disable tablestats. Normally, tablestats is automatically disabled on 1000+ tables (`pmm-admin list` will show this on OPTIONS column).
> 
> To disable tablestats explicitly, re-add “mysql:metrics” service using pmm-admin with --disabla-tablestats flag.

root@yrz\_if 09:42:13\>select count(_) from information\_schema.tables;  
±---------+  
| count(_) |  
±---------+  
| 923 |  
±---------+  
1 row in set (0.01 sec)

ok i will disable tablestats, thank you

---

<div class="post-metadata">

### Author: ![cduffin](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@cduffin](https://forums.percona.com/u/cduffin)
#### Post date: [October 28, 2016, 9:49am UTC](https://forums.percona.com/t/pmm-table-status-this-query-its-very-slow-server-has-hang/5172/4 "2016-10-28T09:49:39Z")

</div>

I have run into a similar issue with a slight variation in the query locking from PMM:

```auto
| 1685363 | root | localhost | NULL | Query | 1371 | Waiting for table metadata lock | SELECT
TABLE_SCHEMA,
TABLE_NAME,
TABLE_TYPE,
ifnull(ENGINE, 'NONE') as ENGINE,
ifnull(VERSION, '0') as VERSION,
ifnull(ROW_FORMAT, 'NONE') as ROW_FORMAT,
ifnull(TABLE_ROWS, '0') as TABLE_ROWS,
ifnull(DATA_LENGTH, '0') as DATA_LENGTH,
ifnull(INDEX_LENGTH, '0') as INDEX_LENGTH,
ifnull(DATA_FREE, '0') as DATA_FREE,
ifnull(CREATE_OPTIONS, 'NONE') as CREATE_OPTIONS
FROM information_schema.tables
WHERE TABLE_SCHEMA = 'squirrel'

```

In this case there were over 180 of this query waiting for a metadata lock.

We currently have 474 tables.

```auto
mysql> select count(*) from information_schema.tables;
+----------+
| count(*) |
+----------+
| 474 |
+----------+

```

---

<div class="post-metadata">

### Author: ![weber](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@weber](https://forums.percona.com/u/weber)
#### Post date: [October 31, 2016, 4:46am UTC](https://forums.percona.com/t/pmm-table-status-this-query-its-very-slow-server-has-hang/5172/5 "2016-10-31T04:46:43Z")

</div>

The same thing - If per table stats queries produce any db performance issues, you can disable them using --disable-tablestats flag.
