Database Stats Connections

Good afternoon,
What's the meaning of connection 0/8 in database stats???

Thank you

Ignition uses connection pooling. That is, it makes multiple simultaneous connections, per each data source's advanced settings, and reuses them over and over and over.

The default is eight. "0/8" means no connections were running any query at that instant, and there were eight connections idling.

Based on the long-running queries in your screenshot, you desperately need a database administrator to analyze your operation and likely create indexes on critical table columns.

For this reason, sometimes in the Log of server ignition there is this Database error????

java.sql.SQLException: Cannot get a connection, pool error Timeout waiting for idle object
at org.apache.commons.dbcp2.PoolingDataSource.getConnection(
at org.apache.commons.dbcp2.BasicDataSource.getConnection(
at com.inductiveautomation.ignition.gateway.datasource.DatasourceImpl.getConnectionInternal(
at com.inductiveautomation.ignition.gateway.datasource.DatasourceManagerImpl.getConnectionImpl(
at com.inductiveautomation.ignition.gateway.datasource.DatasourceImpl.getConnection(
at com.inductiveautomation.ignition.gateway.datasource.DatasourceManagerImpl.getConnection(
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.getConnection(
at com.inductiveautomation.ignition.gateway.servlets.gateway.functions.AbstractDBAction.invoke(
at com.inductiveautomation.ignition.gateway.servlets.Gateway.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at com.inductiveautomation.ignition.gateway.bootstrap.MapServlet.service(
at org.eclipse.jetty.servlet.ServletHolder$NotAsync.service(
at org.eclipse.jetty.servlet.ServletHolder.handle(
at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(
at org.eclipse.jetty.servlet.ServletHandler.doHandle(
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(
at org.eclipse.jetty.server.session.SessionHandler.doHandle(
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(
at org.eclipse.jetty.servlet.ServletHandler.doScope(
at org.eclipse.jetty.server.session.SessionHandler.doScope(
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(
at org.eclipse.jetty.server.handler.ContextHandler.doScope(
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
at com.inductiveautomation.catapult.handlers.RemoteHostNameLookupHandler.handle(
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(
at org.eclipse.jetty.server.handler.HandlerList.handle(
at org.eclipse.jetty.server.handler.HandlerCollection.handle(
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
at org.eclipse.jetty.server.Server.handle(
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(
at org.eclipse.jetty.server.HttpChannel.dispatch(
at org.eclipse.jetty.server.HttpChannel.handle(
at org.eclipse.jetty.server.HttpConnection.onFillable(
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
at org.eclipse.jetty.util.thread.QueuedThreadPool$
at java.base/ Source)
Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(
at org.apache.commons.dbcp2.PoolingDataSource.getConnection(
... 51 common frames omitted

Yes, that is what you get when all of the connections in the pool are busy (typically with pathologically long-running queries) when another query needs to run.

Fix your pathologically long queries.

1 Like

When in the table there are much record, select query are very slow to execute.
How can I speed up execution of this query?
I try to create views but nothing change.

Than you

The most important thing would be to index your tables to suit the queries.

  1. What database are you using? (MySQL, MS SQL, something else?)
  2. What database management tool are you using?

I use Microsoft Sql Server 2014 with Microsoft Sql Server Management Studio

you'll want some indexes on those two id columns you use to filter

1 Like

Excusme, I don't understand

Suggest you outsource this task to a DBA (dataBase Administrator), in that case



in the property Connection Pooling of database connection , I increase number of connection from 8 to 20. Is it possible to increase this value???

In your OP, you were using 0/8. Changing to 20 would only help if you were at 8/8. You have already been advised on how to reduce the database load.

The snapshot shown is a point in time where pool activity was 0/8, but the error indicates that it was stuck at 8/8 for an extended period of time.

But, the underlying cause (poor indices) apparently hasn't been fixed, so a change to a pool size of 20 would simply move the error to 20/20.

@stefano.sforna : The pool size isn't the problem. The long queries times are the problem. You must fix them.

Edit: after another look at the original screen shot, I noticed that some of the long queries have this fragment in their where clauses:

.... WHERE .... cast(someColumn as datetime) BETWEEN 'someStartTS' AND 'someEndTS' ....

That is a pathological filter, as it requires the cast() to be executed on every row in the table before the BETWEEN operator can be applied.

Such must be rewritten in this form:

.... WHERE ... someColumn BETWEEN cast('someStartTS` as someColumnType) AND cast('someEndTS' as someColumnType) ....

In this latter form, the casts are executed just for the endpoints, and those endpoints can then be efficiently applied to any index of someColumn.

Even better would be this form:

.... WHERE ... someColumn BETWEEN ? AND ? ....

where the SQL has no cast at all, and the start/end timestamps are passed unambiguously as JDBC parameters.

1 Like