<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Connection Pool (DataSource) is slow
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/vlc">vlc vlc</a> in <i>Datasource Configuration</i> - <a href="http://community.jboss.org/message/626762#626762">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi Community,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I am using the following MySQL DataSource XML:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><table><tbody><tr><td style=";"></td><td style=";"><jndi-name>MySQLDB</jndi-name></td></tr><tr><td style=";"></td><td style=";"><xa-datasource-property name="URL">jdbc:mysql://127.0.0.1:3306/db</xa-datasource-property></td></tr><tr><td style=";"></td><td style=";"><xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class></td></tr><tr><td style=";"></td><td style=";"><user-name>username</user-name></td></tr><tr><td style=";"></td><td style=";"><password>password</password></td></tr><tr><td style=";"></td><td style=";"><!-- <track-connection-by-tx>true</track-connection-by-tx> --></td></tr><tr><td style=";"></td><td style=";"><exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name></td></tr><tr><td style=";"></td><td style=";"><valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name></td></tr><tr><td style=";"></td><td style=";"><min-pool-size>10</min-pool-size></td></tr><tr><td style=";"></td><td style=";"><max-pool-size>100</max-pool-size></td></tr><tr><td style=";"></td><td style=";"><idle-timeout-minutes>15</idle-timeout-minutes></td></tr><tr><td style=";"></td><td style=";"><blocking-timeout-millis>500</blocking-timeout-millis></td></tr><tr><td style=";"></td><td style=";"><track-statements>true</track-statements></td></tr></tbody></table><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I am doing something like this: </p><p>0. create at application startup DataSource (InitialContext, lookup()) </p><p>1. execute at each request java.sql.Connection = ds.getConnection();</p><p>2. do queries (PreparedStatement-s, ResultSet-s)</p><p>3. close PreparedStatement-s, ResultSet-s, Connection object</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>TEST: I execute 100 or 1000 requests requiring connection to the Database.</p><p>The problem is DataSource.getConnection() takes very often 500 ms ~ 600 ms.</p><p>At every get connection a new WrappedConnection object is returned (but I expect to reuse some already created connections)</p><p>"show processlist" in MySQL show always 10 connections, jmx-console shows the pool is working with information like: created, in-use, destroyed connections.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Please give me some answars:</p><p>1. Why getConnection() function is so slow? </p><p>2. Why diferrent WrappedConnection objects are create at each getConnection() call?</p><p>3. The pool is between 10~100. Why does not exceed 10 connections even I execute 100 or 1000 parallel requests.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thank you for your interest. </p><p>Cristi, </p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/626762#626762">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Datasource Configuration at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>