Documentation Home
MySQL Connector/J 5.1 Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 0.6Mb
PDF (A4) - 0.6Mb


5.3.5 Performance Extensions

  • callableStmtCacheSize

    If 'cacheCallableStmts' is enabled, how many callable statements should be cached?

    Default Value 100
    Since Version 3.1.2
  • metadataCacheSize

    The number of queries to cache ResultSetMetadata for if cacheResultSetMetaData is set to 'true' (default 50)

    Default Value 50
    Since Version 3.1.1
  • useLocalSessionState

    Should the driver refer to the internal values of autocommit and transaction isolation that are set by Connection.setAutoCommit() and Connection.setTransactionIsolation() and transaction state as maintained by the protocol, rather than querying the database or blindly sending commands to the database for commit() or rollback() method calls?

    Default Value false
    Since Version 3.1.7
  • useLocalTransactionState

    Should the driver use the in-transaction state provided by the MySQL protocol to determine if a commit() or rollback() should actually be sent to the database?

    Default Value false
    Since Version 5.1.7
  • prepStmtCacheSize

    If prepared statement caching is enabled, how many prepared statements should be cached?

    Default Value 25
    Since Version 3.0.10
  • prepStmtCacheSqlLimit

    If prepared statement caching is enabled, what's the largest SQL the driver will cache the parsing for?

    Default Value 256
    Since Version 3.0.10
  • parseInfoCacheFactory

    Name of a class implementing com.mysql.jdbc.CacheAdapterFactory, which will be used to create caches for the parsed representation of client-side prepared statements.

    Default Value com.mysql.jdbc.PerConnectionLRUFactory
    Since Version 5.1.1
  • serverConfigCacheFactory

    Name of a class implementing com.mysql.jdbc.CacheAdapterFactory<String, Map<String, String>>, which will be used to create caches for MySQL server configuration values

    Default Value com.mysql.jdbc.PerVmServerConfigCacheFactory
    Since Version 5.1.1
  • alwaysSendSetIsolation

    Should the driver always communicate with the database when Connection.setTransactionIsolation() is called? If set to false, the driver will only communicate with the database when the requested transaction isolation is different than the whichever is newer, the last value that was set via Connection.setTransactionIsolation(), or the value that was read from the server when the connection was established. Note that useLocalSessionState=true will force the same behavior as alwaysSendSetIsolation=false, regardless of how alwaysSendSetIsolation is set.

    Default Value true
    Since Version 3.1.7
  • maintainTimeStats

    Should the driver maintain various internal timers to enable idle time calculations as well as more verbose error messages when the connection to the server fails? Setting this property to false removes at least two calls to System.getCurrentTimeMillis() per query.

    Default Value true
    Since Version 3.1.9
  • useCursorFetch

    If connected to MySQL > 5.0.2, and setFetchSize() > 0 on a statement, should that statement use cursor-based fetching to retrieve rows?

    Default Value false
    Since Version 5.0.0
  • blobSendChunkSize

    Chunk size to use when sending BLOB/CLOBs via ServerPreparedStatements. Note that this value cannot exceed the value of "maxAllowedPacket" and, if that is the case, then this value will be corrected automatically.

    Default Value 1048576
    Since Version 3.1.9
  • cacheCallableStmts

    Should the driver cache the parsing stage of CallableStatements

    Default Value false
    Since Version 3.1.2
  • cachePrepStmts

    Should the driver cache the parsing stage of PreparedStatements of client-side prepared statements, the "check" for suitability of server-side prepared and server-side prepared statements themselves?

    Default Value false
    Since Version 3.0.10
  • cacheResultSetMetadata

    Should the driver cache ResultSetMetaData for Statements and PreparedStatements? (Req. JDK-1.4+, true/false, default 'false')

    Default Value false
    Since Version 3.1.1
  • cacheServerConfiguration

    Should the driver cache the results of 'SHOW VARIABLES' and 'SHOW COLLATION' on a per-URL basis?

    Default Value false
    Since Version 3.1.5
  • defaultFetchSize

    The driver will call setFetchSize(n) with this value on all newly-created Statements

    Default Value 0
    Since Version 3.1.9
  • dontCheckOnDuplicateKeyUpdateInSQL

    Stops checking if every INSERT statement contains the "ON DUPLICATE KEY UPDATE" clause. As a side effect, obtaining the statement's generated keys information will return a list where normally it wouldn't. Also be aware that, in this case, the list of generated keys returned may not be accurate. The effect of this property is canceled if set simultaneously with 'rewriteBatchedStatements=true'.

    Default Value false
    Since Version 5.1.32
  • dontTrackOpenResources

    The JDBC specification requires the driver to automatically track and close resources, however if your application doesn't do a good job of explicitly calling close() on statements or result sets, this can cause memory leakage. Setting this property to true relaxes this constraint, and can be more memory efficient for some applications. Also the automatic closing of the Statement and current ResultSet in Statement.closeOnCompletion() and Statement.getMoreResults ([Statement.CLOSE_CURRENT_RESULT | Statement.CLOSE_ALL_RESULTS]), respectively, ceases to happen. This property automatically sets holdResultsOpenOverStatementClose=true.

    Default Value false
    Since Version 3.1.7
  • dynamicCalendars

    Should the driver retrieve the default calendar when required, or cache it per connection/session?

    Default Value false
    Since Version 3.1.5
  • elideSetAutoCommits

    If using MySQL-4.1 or newer, should the driver only issue 'set autocommit=n' queries when the server's state doesn't match the requested state by Connection.setAutoCommit(boolean)?

    Default Value false
    Since Version 3.1.3
  • enableEscapeProcessing

    Sets the default escape processing behavior for Statement objects. The method Statement.setEscapeProcessing() can be used to specify the escape processing behavior for an individual Statement object. Default escape processing behavior in prepared statements must be defined with the property 'processEscapeCodesForPrepStmts'.

    Default Value true
    Since Version 5.1.37
  • enableQueryTimeouts

    When enabled, query timeouts set via Statement.setQueryTimeout() use a shared java.util.Timer instance for scheduling. Even if the timeout doesn't expire before the query is processed, there will be memory used by the TimerTask for the given timeout which won't be reclaimed until the time the timeout would have expired if it hadn't been cancelled by the driver. High-load environments might want to consider disabling this functionality.

    Default Value true
    Since Version 5.0.6
  • holdResultsOpenOverStatementClose

    Should the driver close result sets on Statement.close() as required by the JDBC specification?

    Default Value false
    Since Version 3.1.7
  • largeRowSizeThreshold

    What size result set row should the JDBC driver consider "large", and thus use a more memory-efficient way of representing the row internally?

    Default Value 2048
    Since Version 5.1.1
  • loadBalanceStrategy

    If using a load-balanced connection to connect to SQL nodes in a MySQL Cluster/NDB configuration (by using the URL prefix "jdbc:mysql:loadbalance://"), which load balancing algorithm should the driver use: (1) "random" - the driver will pick a random host for each request. This tends to work better than round-robin, as the randomness will somewhat account for spreading loads where requests vary in response time, while round-robin can sometimes lead to overloaded nodes if there are variations in response times across the workload. (2) "bestResponseTime" - the driver will route the request to the host that had the best response time for the previous transaction. (3) "serverAffinity" - the driver initially attempts to enforce server affinity while still respecting and benefiting from the fault tolerance aspects of the load-balancing implementation. The server affinity ordered list is provided using the property 'serverAffinityOrder'. If none of the servers listed in the affinity list is responsive, the driver then refers to the "random" strategy to proceed with choosing the next server.

    Default Value random
    Since Version 5.0.6
  • locatorFetchBufferSize

    If 'emulateLocators' is configured to 'true', what size buffer should be used when fetching BLOB data for getBinaryInputStream?

    Default Value 1048576
    Since Version 3.2.1
  • readOnlyPropagatesToServer

    Should the driver issue appropriate statements to implicitly set the transaction access mode on server side when Connection.setReadOnly() is called? Setting this property to 'true' enables InnoDB read-only potential optimizations but also requires an extra roundtrip to set the right transaction state. Even if this property is set to 'false', the driver will do its best effort to prevent the execution of database-state-changing queries. Requires minimum of MySQL 5.6.

    Default Value true
    Since Version 5.1.35
  • rewriteBatchedStatements

    Should the driver use multiqueries (irregardless of the setting of "allowMultiQueries") as well as rewriting of prepared statements for INSERT into multi-value inserts when executeBatch() is called? Notice that this has the potential for SQL injection if using plain java.sql.Statements and your code doesn't sanitize input correctly. Notice that for prepared statements, if you don't specify stream lengths when using PreparedStatement.set*Stream(), the driver won't be able to determine the optimum number of parameters per batch and you might receive an error from the driver that the resultant packet is too large. Statement.getGeneratedKeys() for these rewritten statements only works when the entire batch includes INSERT statements. Please be aware using rewriteBatchedStatements=true with INSERT .. ON DUPLICATE KEY UPDATE that for rewritten statement server returns only one value as sum of all affected (or found) rows in batch and it isn't possible to map it correctly to initial statements; in this case driver returns 0 as a result of each batch statement if total count was 0, and the Statement.SUCCESS_NO_INFO as a result of each batch statement if total count was > 0.

    Default Value false
    Since Version 3.1.13
  • serverAffinityOrder

    A comma-separated list containing the host/port pairs that are to be used in load-balancing "serverAffinity" strategy. Only the subset of the hosts enumerated in the main hosts section in this URL will be used and they must be identical in case and type, i.e., can't use an IP address in one place and the corresponding host name in the other.

    Since Version 5.1.43
  • useDirectRowUnpack

    Use newer result set row unpacking code that skips a copy from network buffers to a MySQL packet instance and instead reads directly into the result set row data buffers.

    Default Value true
    Since Version 5.1.1
  • useDynamicCharsetInfo

    Should the driver use a per-connection cache of character set information queried from the server when necessary, or use a built-in static mapping that is more efficient, but isn't aware of custom character sets or character sets implemented after the release of the JDBC driver?

    Default Value true
    Since Version 5.0.6
  • useFastDateParsing

    Use internal String->Date/Time/Timestamp conversion routines to avoid excessive object creation? This is part of the legacy date-time code, thus the property has an effect only when "useLegacyDatetimeCode=true."

    Default Value true
    Since Version 5.0.5
  • useFastIntParsing

    Use internal String->Integer conversion routines to avoid excessive object creation?

    Default Value true
    Since Version 3.1.4
  • useJvmCharsetConverters

    Always use the character encoding routines built into the JVM, rather than using lookup tables for single-byte character sets?

    Default Value false
    Since Version 5.0.1
  • useReadAheadInput

    Use newer, optimized non-blocking, buffered input stream when reading from the server?

    Default Value true
    Since Version 3.1.5