Top Description Fields Constructors Methods
org.h2.engine

public Class DbSettings

extends SettingsBase
Class Inheritance
Imports
java.util.HashMap, org.h2.api.ErrorCode, org.h2.message.DbException

This class contains various database-level settings. To override the documented default value for a database, append the setting in the database URL: "jdbc:h2:./test;ANALYZE_SAMPLE=1000" when opening the first connection to the database. The settings can not be changed once the database is open.

Some settings are a last resort and temporary solution to work around a problem in the application or database engine. Also, there are system properties to enable features that are not yet fully tested or that are not backward compatible.

Field Summary

Modifier and TypeField and Description
public final int
analyzeAuto

Database setting ANALYZE_AUTO (default: 2000).

public final int
analyzeSample

Database setting ANALYZE_SAMPLE (default: 10000).

public final int
autoCompactFillRate

Database setting AUTO_COMPACT_FILL_RATE (default: 90, which means 90%, 0 disables auto-compacting).

public final boolean
caseInsensitiveIdentifiers

Database setting CASE_INSENSITIVE_IDENTIFIERS (default: false).

public final boolean
compressData

Database setting COMPRESS (default: false).

public final boolean
databaseToLower

Database setting DATABASE_TO_LOWER (default: false).

public final boolean
databaseToUpper

Database setting DATABASE_TO_UPPER (default: true).

public static final DbSettings
DEFAULT

INTERNAL.

public final boolean
defaultConnection

Database setting DEFAULT_CONNECTION (default: false).

public final String
defaultEscape

Database setting DEFAULT_ESCAPE (default: \).

public final String
defaultTableEngine

Database setting DEFAULT_TABLE_ENGINE (default: null).

public final boolean
defragAlways

Database setting DEFRAG_ALWAYS (default: false) Each time the database is closed normally, it is fully defragmented (the same as SHUTDOWN DEFRAG).

public final boolean
dropRestrict

Database setting DROP_RESTRICT (default: true) Whether the default action for DROP TABLE, DROP VIEW, DROP SCHEMA, DROP DOMAIN, and DROP CONSTRAINT is RESTRICT.

public final int
estimatedFunctionTableRows

Database setting ESTIMATED_FUNCTION_TABLE_ROWS (default: 1000).

public final boolean
ignoreCatalogs

Database setting IGNORE_CATALOGS (default: false).

public final int
lobTimeout

Database setting LOB_TIMEOUT (default: 300000, which means 5 minutes).

public final int
maxCompactTime

Database setting MAX_COMPACT_TIME (default: 200).

public final int
maxQueryTimeout

Database setting MAX_QUERY_TIMEOUT (default: 0).

public final boolean
mvStore

Database setting MV_STORE (default: true).

public final boolean
optimizeDistinct

Database setting OPTIMIZE_DISTINCT (default: true).

public final boolean
optimizeEvaluatableSubqueries

Database setting OPTIMIZE_EVALUATABLE_SUBQUERIES (default: true).

public final boolean
optimizeInList

Database setting OPTIMIZE_IN_LIST (default: true).

public final boolean
optimizeInSelect

Database setting OPTIMIZE_IN_SELECT (default: true).

public final boolean
optimizeInsertFromSelect

Database setting OPTIMIZE_INSERT_FROM_SELECT (default: true).

public final boolean
optimizeOr

Database setting OPTIMIZE_OR (default: true).

public final boolean
optimizeSimpleSingleRowSubqueries

Database setting OPTIMIZE_SIMPLE_SINGLE_ROW_SUBQUERIES (default: true).

public final boolean
optimizeTwoEquals

Database setting OPTIMIZE_TWO_EQUALS (default: true).

public final int
queryCacheSize

Database setting QUERY_CACHE_SIZE (default: 8).

public final boolean
recompileAlways

Database setting RECOMPILE_ALWAYS (default: false).

public final boolean
reuseSpace

Database setting REUSE_SPACE (default: true).

public final boolean
shareLinkedConnections

Database setting SHARE_LINKED_CONNECTIONS (default: true).

pack-priv static final int
TABLE_SIZE

The initial size of the hash table.

public final boolean
zeroBasedEnums

Database setting ZERO_BASED_ENUMS (default: false).

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static DbSettings

Returns:

the settings
getInstance
(HashMap<String, String>
the settings
s
)

INTERNAL.

Inherited from org.h2.engine.SettingsBase:
containsKeygetgetgetgetSettingsgetSortedSettingsset

Field Detail

analyzeAutoback to summary
public final int analyzeAuto

Database setting ANALYZE_AUTO (default: 2000). After changing this many rows, ANALYZE is automatically run for a table. Automatically running ANALYZE is disabled if set to 0. If set to 1000, then ANALYZE will run against each user table after about 1000 changes to that table. The time between running ANALYZE doubles each time since starting the database. It is not run on local temporary tables, and tables that have a trigger on SELECT.

analyzeSampleback to summary
public final int analyzeSample

Database setting ANALYZE_SAMPLE (default: 10000). The default sample size when analyzing a table.

autoCompactFillRateback to summary
public final int autoCompactFillRate

Database setting AUTO_COMPACT_FILL_RATE (default: 90, which means 90%, 0 disables auto-compacting). Set the auto-compact target fill rate. If the average fill rate (the percentage of the storage space that contains active data) of the chunks is lower, then the chunks with a low fill rate are re-written. Also, if the percentage of empty space between chunks is higher than this value, then chunks at the end of the file are moved. Compaction stops if the target fill rate is reached. This setting only affects MVStore engine.

caseInsensitiveIdentifiersback to summary
public final boolean caseInsensitiveIdentifiers

Database setting CASE_INSENSITIVE_IDENTIFIERS (default: false). When set to true, all identifier names (table names, column names) are case insensitive. Setting this to "true" is experimental.

compressDataback to summary
public final boolean compressData

Database setting COMPRESS (default: false). Compress data when storing.

databaseToLowerback to summary
public final boolean databaseToLower

Database setting DATABASE_TO_LOWER (default: false). When set to true unquoted identifiers and short name of database are converted to lower case. Value of this setting should not be changed after creation of database. Setting this to "true" is experimental.

databaseToUpperback to summary
public final boolean databaseToUpper

Database setting DATABASE_TO_UPPER (default: true). When set to true unquoted identifiers and short name of database are converted to upper case.

DEFAULTback to summary
public static final DbSettings DEFAULT

INTERNAL. The default settings. Those must not be modified.

defaultConnectionback to summary
public final boolean defaultConnection

Database setting DEFAULT_CONNECTION (default: false). Whether Java functions can use DriverManager.getConnection("jdbc:default:connection") to get a database connection. This feature is disabled by default for performance reasons. Please note the Oracle JDBC driver will try to resolve this database URL if it is loaded before the H2 driver.

defaultEscapeback to summary
public final String defaultEscape

Database setting DEFAULT_ESCAPE (default: \). The default escape character for LIKE comparisons. To select no escape character, use an empty string.

defaultTableEngineback to summary
public final String defaultTableEngine

Database setting DEFAULT_TABLE_ENGINE (default: null). The default table engine to use for new tables.

defragAlwaysback to summary
public final boolean defragAlways

Database setting DEFRAG_ALWAYS (default: false) Each time the database is closed normally, it is fully defragmented (the same as SHUTDOWN DEFRAG). If you execute SHUTDOWN COMPACT, then this setting is ignored.

dropRestrictback to summary
public final boolean dropRestrict

Database setting DROP_RESTRICT (default: true) Whether the default action for DROP TABLE, DROP VIEW, DROP SCHEMA, DROP DOMAIN, and DROP CONSTRAINT is RESTRICT.

estimatedFunctionTableRowsback to summary
public final int estimatedFunctionTableRows

Database setting ESTIMATED_FUNCTION_TABLE_ROWS (default: 1000). The estimated number of rows in a function table (for example, CSVREAD or FTL_SEARCH). This value is used by the optimizer.

ignoreCatalogsback to summary
public final boolean ignoreCatalogs

Database setting IGNORE_CATALOGS (default: false). If set, all catalog names in identifiers are silently accepted without comparing them with the short name of the database.

lobTimeoutback to summary
public final int lobTimeout

Database setting LOB_TIMEOUT (default: 300000, which means 5 minutes). The number of milliseconds a temporary LOB reference is kept until it times out. After the timeout, the LOB is no longer accessible using this reference.

maxCompactTimeback to summary
public final int maxCompactTime

Database setting MAX_COMPACT_TIME (default: 200). The maximum time in milliseconds used to compact a database when closing.

maxQueryTimeoutback to summary
public final int maxQueryTimeout

Database setting MAX_QUERY_TIMEOUT (default: 0). The maximum timeout of a query in milliseconds. The default is 0, meaning no limit. Please note the actual query timeout may be set to a lower value.

mvStoreback to summary
public final boolean mvStore

Database setting MV_STORE (default: true). Use the MVStore storage engine.

optimizeDistinctback to summary
public final boolean optimizeDistinct

Database setting OPTIMIZE_DISTINCT (default: true). Improve the performance of simple DISTINCT queries if an index is available for the given column. The optimization is used if:

  • The select is a single column query without condition
  • The query contains only one table, and no group by
  • There is only one table involved
  • There is an ascending index on the column
  • The selectivity of the column is below 20
optimizeEvaluatableSubqueriesback to summary
public final boolean optimizeEvaluatableSubqueries

Database setting OPTIMIZE_EVALUATABLE_SUBQUERIES (default: true). Optimize subqueries that are not dependent on the outer query.

optimizeInListback to summary
public final boolean optimizeInList

Database setting OPTIMIZE_IN_LIST (default: true). Optimize IN(...) and IN(SELECT ...) comparisons. This includes optimization for SELECT, DELETE, and UPDATE.

optimizeInSelectback to summary
public final boolean optimizeInSelect

Database setting OPTIMIZE_IN_SELECT (default: true). Optimize IN(SELECT ...) comparisons. This includes optimization for SELECT, DELETE, and UPDATE.

optimizeInsertFromSelectback to summary
public final boolean optimizeInsertFromSelect

Database setting OPTIMIZE_INSERT_FROM_SELECT (default: true). Insert into table from query directly bypassing temporary disk storage. This also applies to create table as select.

optimizeOrback to summary
public final boolean optimizeOr

Database setting OPTIMIZE_OR (default: true). Convert (C=? OR C=?) to (C IN(?, ?)).

optimizeSimpleSingleRowSubqueriesback to summary
public final boolean optimizeSimpleSingleRowSubqueries

Database setting OPTIMIZE_SIMPLE_SINGLE_ROW_SUBQUERIES (default: true). Optimize expressions of the form (SELECT A) to A.

optimizeTwoEqualsback to summary
public final boolean optimizeTwoEquals

Database setting OPTIMIZE_TWO_EQUALS (default: true). Optimize expressions of the form A=B AND B=1. In this case, AND A=1 is added so an index on A can be used.

queryCacheSizeback to summary
public final int queryCacheSize

Database setting QUERY_CACHE_SIZE (default: 8). The size of the query cache, in number of cached statements. Each session has it's own cache with the given size. The cache is only used if the SQL statement and all parameters match. Only the last returned result per query is cached. The following statement types are cached: SELECT statements are cached (excluding UNION and FOR UPDATE statements), CALL if it returns a single value, DELETE, INSERT, MERGE, UPDATE, and transactional statements such as COMMIT. This works for both statements and prepared statement.

recompileAlwaysback to summary
public final boolean recompileAlways

Database setting RECOMPILE_ALWAYS (default: false). Always recompile prepared statements.

reuseSpaceback to summary
public final boolean reuseSpace

Database setting REUSE_SPACE (default: true). If disabled, all changes are appended to the database file, and existing content is never overwritten. This setting has no effect if the database is already open.

shareLinkedConnectionsback to summary
public final boolean shareLinkedConnections

Database setting SHARE_LINKED_CONNECTIONS (default: true). Linked connections should be shared, that means connections to the same database should be used for all linked tables that connect to the same database.

TABLE_SIZEback to summary
pack-priv static final int TABLE_SIZE

The initial size of the hash table.

zeroBasedEnumsback to summary
public final boolean zeroBasedEnums

Database setting ZERO_BASED_ENUMS (default: false). If set, ENUM ordinal values are 0-based.

Constructor Detail

DbSettingsback to summary
private DbSettings(HashMap<String, String> s)

Method Detail

getInstanceback to summary
pack-priv static DbSettings getInstance(HashMap<String, String> s)

INTERNAL. Get the settings for the given properties (may not be null).

Parameters
s:HashMap<String, String>

the settings

Returns:DbSettings

the settings