5.10.2 Work tables created when SQL statements are executed
Work tables are created when you execute the SQL statements listed in the table below.
- Important
-
If the row length of the work table exceeds the maximum row length, the SQL statement will result in an error. For details about the maximum row length of a work table, see Maximum and minimum values related to database in the HADB Setup and Operation Guide. For details about how to determine the row length of a work table, see the description of variable ROWSZ in Determining the number of pages for base rows that are needed for storing work tables in the HADB Setup and Operation Guide.
No. |
SQL statement for which work table is created |
Purpose of work table |
Columns of work table |
Work table type |
|
---|---|---|---|---|---|
1 |
ORDER BY clause is specified. |
Results of a set operation are used as a sort key. |
Sorting the retrieval results |
|
Local work table |
Results of a query specification are used as a sort key. |
|
||||
2 |
GROUP BY clause is specified. |
The grouping method is global hash grouping.#2 |
Retaining the grouping results. This work table is used when a shortage occurs in the hash table area. The size of the hash table area is specified in the adb_sql_exe_hashtbl_area_size operand in the server definition or the client definition. |
|
|
The grouping method is local hash grouping#2 |
Sorting for grouping. This work table is used when there is insufficient hash grouping area. The size of the hash grouping area is specified in the adb_sql_exe_hashgrp_area_size operand in the server or client definition. |
|
Local work table |
||
The grouping method is sort grouping#2. |
Sorting for grouping. |
||||
3 |
SELECT DISTINCT is specified. |
The method for processing SELECT DISTINCT is hash execution.#12 |
Retaining retrieval results. This work table is used when a shortage occurs in the hash table area. The size of the hash table area is specified in the adb_sql_exe_hashtbl_area_size operand in the server definition or the client definition. |
|
|
The method for processing SELECT DISTINCT is work table execution.#12 |
Sorting retrieval results or eliminating duplicate retrieval results |
|
Local work table |
||
4 |
DISTINCT set function or inverse distribution function is specified. |
The grouping method is global hash grouping.#2 |
Retaining the input values of set functions whose duplicates have been eliminated. This work table is used when a shortage occurs in the hash table area. The size of the hash table area is specified in the adb_sql_exe_hashtbl_area_size operand in the server definition or the client definition. |
|
|
The grouping method is not global hash grouping.#2 |
Eliminating the duplicates of input values for set functions or sorting the input values for set functions |
||||
5 |
Window functions are specified. |
Sorting for obtaining the results of window functions |
|
Local work table |
|
6 |
Multiple table references are specified in the FROM clause. |
The table joining method is hash join.#3 |
Retaining the results of table references subject to table join processing. This work table is used when a shortage occurs in the hash table area. The size of the hash table area is specified in the adb_sql_exe_hashtbl_area_size operand in the server definition or the client definition. |
|
|
The table joining method is nested loop join.#3 |
Retaining the results of table references subject to table join processing |
Global work table |
|||
7 |
Derived tables are specified. |
Retaining the results of query expression bodies corresponding to derived tables |
|
Global work table |
|
8 |
Viewed tables are specified. |
Retaining the results of query expressions corresponding to viewed tables |
|
Global work table |
|
9 |
WITH clause is specified. |
Retaining the results of query expression bodies corresponding to query names |
|
Global work table |
|
10 |
A table function derived table is specified. |
Retaining the results of system-defined functions that derive table function derived tables. |
|
Global work table |
|
11 |
Joined tables are specified. |
Retaining the results of joined tables. For details about the work tables used to obtain the results of joined tables, see Multiple table references are specified in the FROM clause in row 6. |
|
Global work table |
|
12 |
Subqueries are specified. |
The subquery processing method is hash execution.#4 |
Retaining the results of subqueries. This work table is used when a shortage occurs in the hash table area. The size of the hash table area is specified in the adb_sql_exe_hashtbl_area_size operand in the server definition or the client definition. |
|
|
The subquery processing method is not hash execution.#4 |
Retaining the results of subqueries |
|
Global work table |
||
13 |
A set operation is specified. |
The method for processing the set operation is hash execution.#13 |
Retaining the results of deduplication. This work table is used when a shortage occurs in the hash table area. The size of the hash table area is specified in the adb_sql_exe_hashtbl_area_size operand in the server definition or the client definition. |
|
|
The method for processing the set operation is work table execution.#13 |
Sorting retrieval results or eliminating duplicate retrieval results |
|
Local work table |
||
14 |
A recursive query is specified. |
Retaining the results of anchor members and recursive members |
|
Global work table |
- #1
-
The row ID is a value that indicates a row's storage location. The data type of a row ID is CHAR(16).
- #2
-
For details about grouping methods, see 5.7 Grouping methods.
- #3
-
For details about table joining methods, see 5.5 Table joining methods.
- #4
-
For details about how to process subqueries, see 5.6 How to process subqueries.
- #5
-
For details about external reference columns, see Specification format and rules for subqueries in the manual HADB SQL Reference.
- #6
-
Expansion of the internal derived table might result in this table being handled as the base table. For details about expansion of internal derived tables, see Internal derived tables in the manual HADB SQL Reference.
- #7
-
A work table used to store data that the hash table area cannot accommodate due to insufficient space.
- #8
-
A work table used to store data that cannot be processed because there is still insufficient hash table area after data has been stored in work tables.
- #9
-
The data type of columns that store the information HADB uses for hashing is INTEGER.
- #10
-
A column created in a work table used to store data that cannot be processed because there is still insufficient hash table area after data has been stored in work tables.
- #11
-
Columns with a definition length of 128 or more bytes are not subject to retrieval. A column with a definition length of 128 or more bytes refers to any of the following columns:
-
A column of CHARACTER type with a definition length of 128 or more bytes
-
A column of VARCHAR type with a definition length of 128 or more bytes
-
A column of BINARY type with a definition length of 128 or more bytes
-
A column of VARBINARY type with a definition length of 128 or more bytes
-
- #12
-
For details about the method for processing SELECT DISTINCT, see 5.9 Method for processing SELECT DISTINCT.
- #13
-
For details about the method for processing the set operation, see 5.8 Methods for processing set operations.
You can find out whether work tables were created by checking the access path after the SQL statement has executed. For details about access paths, see the following sections:
-
How to check access paths
-
Information displayed in access paths
See (7) Work table creation information in 6.1.4 Information displayed in the tree view.