# ProxySQL Stmt\_Server\_Active\_Total much higher then it should be

**URL:** <https://forums.percona.com/t/proxysql-stmt-server-active-total-much-higher-then-it-should-be/6915>\
**Category:** Other Tools\
**Created:** [March 19, 2019, 6:28pm UTC](https://forums.percona.com/t/proxysql-stmt-server-active-total-much-higher-then-it-should-be/6915 "2019-03-19T18:28:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufjohn](https://avatars.discourse-cdn.com/v4/letter/u/54ee81/32.png) [@ufjohn](https://forums.percona.com/u/ufjohn)\
**Post date:** [March 19, 2019, 6:28pm UTC](https://forums.percona.com/t/proxysql-stmt-server-active-total-much-higher-then-it-should-be/6915/1 "2019-03-19T18:28:39Z")

</div>

Is there a setting I’m missing?

My understanding is that the maximum number of prepared statements is . In my case, that should be a theoretical maximum of about 8K prepared statements, but I’m often almost double that number. In fact, my active connections are much lower than the max.

Here are some stats - All taken at the same time from my proxysql node:

proxysql\> show variables like “%stmt%”;  
±-------------------------------±------+  
| Variable\_name | Value |  
±-------------------------------±------+  
| mysql-max\_stmts\_per\_connection | 20 |  
| mysql-max\_stmts\_cache | 10000 |  
±-------------------------------±------+  
2 rows in set (0.00 sec)  
proxysql\> SELECT \* FROM stats\_mysql\_connection\_pool;  
±----------±---------------±---------±-------------±---------±---------±-------±--------±--------±----------------±----------------±-----------+  
| hostgroup | srv\_host | srv\_port | status | ConnUsed | ConnFree | ConnOK | ConnERR | Queries | Bytes\_data\_sent | Bytes\_data\_recv | Latency\_us |  
±----------±---------------±---------±-------------±---------±---------±-------±--------±--------±----------------±----------------±-----------+  
| 10 | XXX.XXX.XX.173 | 3306 | ONLINE | 79 | 5 | 84 | 0 | 576172 | 82951515 | 454089261 | 772 |  
| 10 | XXX.XXX.XX.174 | 3306 | OFFLINE\_SOFT | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 732 |  
| 11 | XXX.XXX.XX.173 | 3306 | ONLINE | 46 | 3 | 49 | 0 | 498427 | 33312388 | 30330862 | 772 |  
| 11 | XXX.XXX.XX.174 | 3306 | ONLINE | 27 | 13 | 40 | 0 | 297624 | 24769155 | 26670950 | 732 |  
±----------±---------------±---------±-------------±---------±---------±-------±--------±--------±----------------±----------------±-----------+  
4 rows in set (0.00 sec)  
proxysql\> SELECT \* FROM stats\_mysql\_global WHERE variable\_name LIKE ‘%stmt%’;  
±--------------------------±---------------+  
| Variable\_Name | Variable\_Value |  
±--------------------------±---------------+  
| Com\_backend\_stmt\_prepare | 402827 |  
| Com\_backend\_stmt\_execute | 899605 |  
| Com\_backend\_stmt\_close | 0 |  
| Com\_frontend\_stmt\_prepare | 900848 |  
| Com\_frontend\_stmt\_execute | 900035 |  
| Com\_frontend\_stmt\_close | 899332 |  
| Stmt\_Client\_Active\_Total | 11 |  
| Stmt\_Client\_Active\_Unique | 11 |  
| Stmt\_Server\_Active\_Total | 16551 |  
| Stmt\_Server\_Active\_Unique | 14014 |  
| Stmt\_Max\_Stmt\_id | 16273 |  
| Stmt\_Cached | 14736 |  
±--------------------------±---------------+  
12 rows in set (0.00 sec)

So, it looks like I have a total of 173 connections open. 173 \* 20 = 3,460. Why are there \>16K active statements?

The number of active statements show my proxysql matches up with why my percona DB is telling me as well.
