Buffer scan

The buffer scan operation is used when a query is processed using DB2® UDB Symmetric Multiprocessing, yet a portion of the query is not enabled to be processed under parallelism. The buffer scan acts as a gateway to control access to rows between the parallel enabled portions of the query and the non-parallel portions.

Multiple threads can be used to fetch the selected rows from the buffer, allowing the query to perform any remaining processing in parallel. However, the buffer will be populated in a non-parallel manner.

A buffer scan operation is identical to the list scan operation that is performed upon the temporary list object. The main difference is that a buffer does not need to be fully populated before the start of the scan operation. A temporary list requires that the list is fully populated before fetching any rows.

Table 1. Buffer scan attributes
Data access method Buffer scan
Description Sequentially scan and process all of the rows in the temporary buffer. Enables SMP parallelism to be performed over a non-parallel portion of the query.
Advantages
  • The temporary buffer can be used to enable parallelism over a portion of a query that is non-parallel
  • The temporary buffer does not need to be fully populated in order to start fetching rows
Considerations Generally used to prevent portions of the query from being processed multiple times when no key columns are required to satisfy the request.
Likely to be used
  • When the query is attempting to take advantage of DB2 UDB Symmetric Multiprocessing
  • When a portion of the query cannot be performed in parallel (for example, index scan or index probe)
Example SQL statement
CHGQRYA DEGREE(*OPTIMIZE)
CREATE INDEX X1 ON 
     Employee (LastName, WorkDept)

SELECT * FROM Employee
WHERE WorkDept BETWEEN 'A01' AND 'E01'
AND LastName IN ('Smith', 'Jones', 'Peterson')
OPTIMIZE FOR ALL ROWS
Messages indicating use
  • Optimizer Debug:
    CPI4328 -- Access path of file X1 was used by query.
    CPI4330 -- 8 tasks used for parallel index scan
               of file EMPLOYEE.
  • PRTSQLINF:
    SQL4027 -- Access plan was saved with DB2 UDB
               SMP installed on the system.
    SQL4008 -- Index X1 used for table 1.
    SQL4011 -- Index scan-key row positioning
               used on table 1.
    SQL4030 -- 8 tasks specified for parallel scan
               on table 1.
SMP parallel enabled Yes
Also referred to as Not applicable
Visual Explain icon
Buffer scan icon

Using the example above, the optimizer chose to use the existing index X1 to perform an index probe operation against the table. In order to speed up the remaining processing for this query (for example, the Table Probe operation), DB2 Symmetric Multiprocessing will be used to perform the random probe into the table. Since the index probe operation is not SMP parallel enabled for the SQL Query Engine, that portion of the query is placed within a temporary buffer to control access to the selected index entries.