Package org.h2.engine
Class DbSettings
java.lang.Object
org.h2.engine.SettingsBase
org.h2.engine.DbSettings
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 TypeFieldDescriptionfinal int
Database settingANALYZE_AUTO
(default: 2000).final int
Database settingANALYZE_SAMPLE
(default: 10000).final int
Database settingAUTO_COMPACT_FILL_RATE
(default: 90, which means 90%, 0 disables auto-compacting).final boolean
Database settingCASE_INSENSITIVE_IDENTIFIERS
(default: false).final boolean
Database settingCOMPRESS
(default: false).final boolean
Database settingDATABASE_TO_LOWER
(default: false).final boolean
Database settingDATABASE_TO_UPPER
(default: true).static final DbSettings
INTERNAL.final boolean
Database settingDEFAULT_CONNECTION
(default: false).final String
Database settingDEFAULT_ESCAPE
(default: \).final String
Database settingDEFAULT_TABLE_ENGINE
(default: null).final boolean
Database settingDEFRAG_ALWAYS
(default: false) Each time the database is closed normally, it is fully defragmented (the same as SHUTDOWN DEFRAG).final boolean
Database settingDROP_RESTRICT
(default: true) Whether the default action for DROP TABLE, DROP VIEW, DROP SCHEMA, DROP DOMAIN, and DROP CONSTRAINT is RESTRICT.final int
Database settingESTIMATED_FUNCTION_TABLE_ROWS
(default: 1000).final boolean
Database settingIGNORE_CATALOGS
(default: false).final int
Database settingLOB_TIMEOUT
(default: 300000, which means 5 minutes).final int
Database settingMAX_COMPACT_TIME
(default: 200).final int
Database settingMAX_QUERY_TIMEOUT
(default: 0).final boolean
Database settingMV_STORE
(default: true).final boolean
Database settingOPTIMIZE_DISTINCT
(default: true).final boolean
Database settingOPTIMIZE_EVALUATABLE_SUBQUERIES
(default: true).final boolean
Database settingOPTIMIZE_IN_LIST
(default: true).final boolean
Database settingOPTIMIZE_IN_SELECT
(default: true).final boolean
Database settingOPTIMIZE_INSERT_FROM_SELECT
(default: true).final boolean
Database settingOPTIMIZE_OR
(default: true).final boolean
Database settingOPTIMIZE_SIMPLE_SINGLE_ROW_SUBQUERIES
(default: true).final boolean
Database settingOPTIMIZE_TWO_EQUALS
(default: true).final int
Database settingQUERY_CACHE_SIZE
(default: 8).final boolean
Database settingRECOMPILE_ALWAYS
(default: false).final boolean
Database settingREUSE_SPACE
(default: true).final boolean
Database settingSHARE_LINKED_CONNECTIONS
(default: true).final boolean
Database settingZERO_BASED_ENUMS
(default: false). -
Method Summary
Methods inherited from class org.h2.engine.SettingsBase
containsKey, get, get, get, getSettings, getSortedSettings
-
Field Details
-
DEFAULT
INTERNAL. The default settings. Those must not be modified. -
analyzeAuto
public final int analyzeAutoDatabase settingANALYZE_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. -
analyzeSample
public final int analyzeSampleDatabase settingANALYZE_SAMPLE
(default: 10000). The default sample size when analyzing a table. -
autoCompactFillRate
public final int autoCompactFillRateDatabase settingAUTO_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. -
databaseToLower
public final boolean databaseToLowerDatabase settingDATABASE_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. -
databaseToUpper
public final boolean databaseToUpperDatabase settingDATABASE_TO_UPPER
(default: true). When set to true unquoted identifiers and short name of database are converted to upper case. -
caseInsensitiveIdentifiers
public final boolean caseInsensitiveIdentifiersDatabase settingCASE_INSENSITIVE_IDENTIFIERS
(default: false). When set to true, all identifier names (table names, column names) are case insensitive. Setting this to "true" is experimental. -
defaultConnection
public final boolean defaultConnectionDatabase settingDEFAULT_CONNECTION
(default: false). Whether Java functions can useDriverManager.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. -
defaultEscape
Database settingDEFAULT_ESCAPE
(default: \). The default escape character for LIKE comparisons. To select no escape character, use an empty string. -
defragAlways
public final boolean defragAlwaysDatabase settingDEFRAG_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. -
dropRestrict
public final boolean dropRestrictDatabase settingDROP_RESTRICT
(default: true) Whether the default action for DROP TABLE, DROP VIEW, DROP SCHEMA, DROP DOMAIN, and DROP CONSTRAINT is RESTRICT. -
estimatedFunctionTableRows
public final int estimatedFunctionTableRowsDatabase settingESTIMATED_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. -
lobTimeout
public final int lobTimeoutDatabase settingLOB_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. -
maxCompactTime
public final int maxCompactTimeDatabase settingMAX_COMPACT_TIME
(default: 200). The maximum time in milliseconds used to compact a database when closing. -
maxQueryTimeout
public final int maxQueryTimeoutDatabase settingMAX_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. -
optimizeDistinct
public final boolean optimizeDistinctDatabase settingOPTIMIZE_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
-
optimizeEvaluatableSubqueries
public final boolean optimizeEvaluatableSubqueriesDatabase settingOPTIMIZE_EVALUATABLE_SUBQUERIES
(default: true). Optimize subqueries that are not dependent on the outer query. -
optimizeInsertFromSelect
public final boolean optimizeInsertFromSelectDatabase settingOPTIMIZE_INSERT_FROM_SELECT
(default: true). Insert into table from query directly bypassing temporary disk storage. This also applies to create table as select. -
optimizeInList
public final boolean optimizeInListDatabase settingOPTIMIZE_IN_LIST
(default: true). Optimize IN(...) and IN(SELECT ...) comparisons. This includes optimization for SELECT, DELETE, and UPDATE. -
optimizeInSelect
public final boolean optimizeInSelectDatabase settingOPTIMIZE_IN_SELECT
(default: true). Optimize IN(SELECT ...) comparisons. This includes optimization for SELECT, DELETE, and UPDATE. -
optimizeOr
public final boolean optimizeOrDatabase settingOPTIMIZE_OR
(default: true). Convert (C=? OR C=?) to (C IN(?, ?)). -
optimizeTwoEquals
public final boolean optimizeTwoEqualsDatabase settingOPTIMIZE_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. -
optimizeSimpleSingleRowSubqueries
public final boolean optimizeSimpleSingleRowSubqueriesDatabase settingOPTIMIZE_SIMPLE_SINGLE_ROW_SUBQUERIES
(default: true). Optimize expressions of the form (SELECT A) to A. -
queryCacheSize
public final int queryCacheSizeDatabase settingQUERY_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. -
recompileAlways
public final boolean recompileAlwaysDatabase settingRECOMPILE_ALWAYS
(default: false). Always recompile prepared statements. -
reuseSpace
public final boolean reuseSpaceDatabase settingREUSE_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. -
defaultTableEngine
Database settingDEFAULT_TABLE_ENGINE
(default: null). The default table engine to use for new tables. -
mvStore
public final boolean mvStoreDatabase settingMV_STORE
(default: true). Use the MVStore storage engine. -
compressData
public final boolean compressDataDatabase settingCOMPRESS
(default: false). Compress data when storing. -
ignoreCatalogs
public final boolean ignoreCatalogsDatabase settingIGNORE_CATALOGS
(default: false). If set, all catalog names in identifiers are silently accepted without comparing them with the short name of the database. -
zeroBasedEnums
public final boolean zeroBasedEnumsDatabase settingZERO_BASED_ENUMS
(default: false). If set, ENUM ordinal values are 0-based.
-