AUTOLOCATE session environment option
Use the AUTOLOCATE environment option of the SET ENVIRONMENT statement to enable or disable the automatic location of databases, indexes, and permanent tables.
Setting this session environment option to an integer value greater than '0' but less than '33' also enables round-robin fragmentation as the default distributed storage for new tables created during the current session, using the AUTOLOCATE setting as the initially allocated number of fragments.
The SET ENVIRONMENT AUTOLOCATE statement of SQL supports the following syntax:
AUTOLOCATE environment option |--SET ENVIRONMENT AUTOLOCATE--+-'0'-----------+----------------| '-'--integer--'-'
Element | Description | Restrictions | Syntax |
---|---|---|---|
integer | Nonnegative integer that defines how many round-robin fragments to allocate initially | Must be in the range 1 ≤ integer ≤ 32 | Quoted String |
Usage
The AUTOLOCATE session environment option can have the following values:
- '0' or "0"
- Disables automatic location and implicit fragmentation during the current session.
- 'integer' or "integer" where 1 ≤ integer ≤ 32
- Enables automatic location and round-robin fragmentation. The integer value defines how many round-robin fragments to initially allocate to each permanent table created in the current session.
The current setting of the AUTOLOCATE option overrides the value of the AUTOLOCATE configuration parameter during the current session.
Effect of automatic location on the CREATE DATABASE statement
The setting of the AUTOLOCATE session environment option affects CREATE DATABASE statements that include no IN clause list of dbspaces.
SET ENVIRONMENT AUTOLOCATE '2';
CREATE DATABASE IF NOT EXISTS stores_new
WITH LOG NLSCASE SENSITIVE;
- The stores_new database will not be created in the root dbspace, if a noncritical dbspace is available.
- Dbspaces with the smallest page size will be favored over those with larger pages.
- Dbspaces with the most free space will be favored.
- Dbspaces with extendable chunks will be favored.
If the AUTOLOCATE configuration parameter has a valid setting greater than 0, the above criteria for automatically choosing a dbspace are already in effect.
CREATE DATABASE IF NOT EXISTS stores_newer IN dbsp04, dbsp05
WITH LOG NLSCASE SENSITIVE;
Databases like stores_newer that
are created without automatic location can store tables and indexes
whose storage location and fragmentation are based on the AUTOLOCATE
session environment setting. For example, any permanent table or index
that is created in the stores_newer database during a session
with the AUTOLOCATE session environment option enabled can use implicit
round-robin fragmentation for fragments in the dbsp04 and dbsp05 dbspaces,
if the table or index is created without the Storage Options clause.Effect on CREATE TABLE statements
- The database server implicitly uses round-robin distributed storage for each permanent table that is created without a Storage Options clause, allocating two fragments, as specified by the AUTOLOCATE session environment setting.
- The dbspaces that store those fragments will be chosen automatically, based on the same criteria identified above for the CREATE DATABASE statement.
Effect on CREATE INDEX statements
- The database creates a nonfragmented index by default in a dbspace chosen by the server, based on the above criteria. The same index will also store index-key information about rows in any additional table fragments that the database creates automatically, if the storage capacity limit or the maximum number of rows is exceeded for both of the initially allocated table fragments.
- You cannot apply the IN TABLE storage option of the CREATE INDEX statement to indexes on tables that are implicitly fragmented by the SET ENVIRONMENT AUTOLOCATE session environment option.
Effect on permanent result tables of SELECT statements
SELECT col1::INT fcol1, col2
FROM tab1 INTO STANDARD MyResultTab;
Because the AUTOLOCATE
session environment setting is '2', the database
server automatically allocates two fragments for the MyResultTab permanent
table that the SELECT statement created. The AUTOLOCATE setting has no effect, however, on result tables created with the INTO TEMP or INTO EXTERNAL keyword options, or on result tables created with a Storage Options clause.
Effect on other DML operations that insert rows
- It creates a new round-robin fragment of the same page size as the original fragments, allocating this in a dbspace that has enough free pages. As in the case of CREATE DATABASE, if noncritical dbspaces are available, the database server does not choose critical dbspaces.
- After the new fragment is automatically attached to the table, the database server resumes inserting rows for the current INSERT, LOAD, or MERGE operation.
SET ENVIRONMENT AUTOLOCATE '9';
.SET ENVIRONMENT AUTOLOCATE '1';
The
fragment is initially empty, but if rows are inserted into the table,
all are inserted into that fragment, because no other exists. Tables
created in the session with implicit fragmentation can be referenced
by the ALTER FRAGMENT statement, despite their superficial resemblance
to nonfragmented tables. When no additional rows can be inserted
into the original fragment, the database server automatically attaches
a new round-robin fragment to the table.See also the IBM® Informix® Administrator's Reference for information about how to run admin( ) and task( ) SQL administration API commands with one of the autolocate datatabase arguments to manage the list of dbspaces that can store table fragments created with automatic location enabled by the AUTOLOCATE environment option or by the AUTOLOCATE configuration parameter.
Disabling automatic location and implicit fragmentation
SET ENVIRONMENT AUTOLOCATE '0';
This
setting only affects databases, indexes, and permanent tables that
are created by subsequent DDL operations in the current session, Other
sessions follow the behavior that corresponds to the AUTOLOCATE configuration
parameter setting, or to SET ENVIRONMENT AUTOLOCATE statements issued
in those sessions.- Databases are created by default in the root dbspace, or in the dbspace that the IN clause of the CREATE DATABASE statement specifies,
- Tables are created without implicit fragmentation, and stored according to the default or explicit Storage Options clauses of the CREATE TABLE, ALTER TABLE, and ALTER FRAGMENT statements.
- New round-robin fragments are not created automatically when all existing fragments of the table are at their limit for storage size or for the number of rows in a fragment.