ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzajq_5.4.0.1/rzajqbitscan.htm

153 lines
9.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Bitmap scan" />
<meta name="abstract" content="During a bitmap scan operation, the entire temporary bitmap is scanned and all of the row addresses contained within the bitmap will be processed. A bitmap scan is generally considered when the optimizer is considering a plan that involves an encoded vector index or if the cost of the random I/O associated with an index probe or scan operation can be reduced by first preprocessing and sorting the row numbers associated with the Table Probe operation." />
<meta name="description" content="During a bitmap scan operation, the entire temporary bitmap is scanned and all of the row addresses contained within the bitmap will be processed. A bitmap scan is generally considered when the optimizer is considering a plan that involves an encoded vector index or if the cost of the random I/O associated with an index probe or scan operation can be reduced by first preprocessing and sorting the row numbers associated with the Table Probe operation." />
<meta name="DC.subject" content="definitions, bitmap scan access method, temporary bitmap, scan access method, bitmap scan, access method, access method" />
<meta name="keywords" content="definitions, bitmap scan access method, temporary bitmap, scan access method, bitmap scan, access method, access method" />
<meta name="DC.Relation" scheme="URI" content="rzajqtempbit.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzajqbitscan" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Bitmap scan</title>
</head>
<body id="rzajqbitscan"><a name="rzajqbitscan"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Bitmap scan</h1>
<div><p>During a bitmap scan operation, the entire temporary bitmap is
scanned and all of the row addresses contained within the bitmap will be processed.
A bitmap scan is generally considered when the optimizer is considering a
plan that involves an encoded vector index or if the cost of the random I/O
associated with an index probe or scan operation can be reduced by first preprocessing
and sorting the row numbers associated with the Table Probe operation.</p>
<div class="section"><p>The use of a bitmap scan will allow the optimizer to generate
a plan that can take advantage of multiple indexes to match up to different
portions of the query.</p>
</div>
<div class="section"><p>An additional benefit of using a bitmap scan is that the data
structure of the temporary bitmap guarantees that the row numbers are sorted;
it closely mirrors the row number layout of the table data ensuring that the
paging on the table will never revisit the same page of data twice. This results
in increased I/O savings for the query.</p>
</div>
<div class="section"><p>A bitmap scan is identical to a row number list scan operation.
The only difference between the two operations is that a row number list scan
is performed over a list of row addresses while the bitmap scan is performed
over a bitmap that represents the row addresses.</p>
</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><caption>Table 1. Bitmap scan attributes</caption><thead align="left"><tr><th valign="top" width="30.96446700507614%" id="d0e46">Data access method</th>
<th valign="top" width="69.03553299492386%" id="d0e48">Bitmap scan attributes</th>
</tr>
</thead>
<tbody><tr><td valign="top" width="30.96446700507614%" headers="d0e46 "><strong>Description</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e48 ">Sequentially scan and process all of the row numbers
in the temporary bitmap. The sorted row numbers can be merged with other temporary
bitmaps or can be used as input into a Table Probe operation.</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e46 "><strong>Advantages</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e48 "><ul><li>The temporary bitmap only contains a reference to a rows' address, no
data, so the temporary can be efficiently scanned within memory</li>
<li>The row numbers represented within the temporary object are sorted to
provide efficient I/O processing to access the underlying table</li>
<li>Selection is performed as the bitmap is generated to subset the number
of selected rows in the temporary object</li>
</ul>
</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e46 "><strong>Considerations</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e48 ">Since the bitmap only contains the addresses of the
selected row in the table, a separate Table Probe operation must be performed
in order to fetch the table rows </td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e46 "><strong>Likely to be used</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e48 "><ul><li>When the use of temporary results is allowed by the query environmental
parameter (ALWCPYDTA) </li>
<li>When the cost of sorting of the row numbers is justified by the more efficient
I/O that can be performed during the Table Probe operation</li>
<li>When multiple indexes over the same table need to be combined in order
to minimize the number of selected rows</li>
</ul>
</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e46 "><strong>Example SQL statement</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e48 "><pre>CREATE INDEX X1 ON Employee (WorkDept)
CREATE ENCODED VECTOR INDEX EVI2 ON
Employee (Salary)
CREATE ENCODED VECTOR INDEX EVI3 ON
Employee (Job)
SELECT * FROM Employee
WHERE WorkDept = 'E01' AND Job = 'CLERK'
AND Salary = 5000
OPTIMIZE FOR 99999 ROWS</pre>
</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e46 "><strong>Messages indicating use</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e48 ">There are multiple ways in which a bitmap scan can be
indicated through the messages. The messages in this example illustrate how
the Classic Query Engine will indicate a bitmap scan was used. <ul><li>Optimizer Debug: <pre>CPI4329 -- Arrival sequence was used for file
EMPLOYEE.
CPI4338 - 3 Access path(s) used for bitmap
processing of file EMPLOYEE.</pre>
</li>
<li>PRTSQLINF: <pre>SQL4010 -- Table scan access for table 1.
SQL4032 -- Index X1 used for bitmap
processing of table 1.
SQL4032 -- Index EVI2 used for bitmap
processing of table 1.
SQL4032 -- Index EVI3 used for bitmap
processing of table 1. </pre>
</li>
</ul>
</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e46 "><strong>SMP parallel enabled</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e48 ">Yes</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e46 "><strong>Also referred to as</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e48 ">Bitmap Scan, Preload <p>Row Number Bitmap Scan</p>
<p>Row
Number Bitmap Scan, Preload</p>
<p>Skip Sequential Scan</p>
</td>
</tr>
<tr><td valign="top" width="30.96446700507614%" headers="d0e46 "><strong>Visual Explain icon</strong></td>
<td valign="top" width="69.03553299492386%" headers="d0e48 "><br /><img src="rzajq527.gif" alt="Bitmap scan icon" /><br /></td>
</tr>
</tbody>
</table>
</div>
<div class="section"><p>Using the example above, the optimizer created a temporary bitmap
for each of the indexes used by his query. This query used a combination of
a radix index and two encoded vector indexes to create the row number lists.
The temporary bitmaps for each index were scanned and merged into a final
composite bitmap that represents the intersection of the rows represented
by all of the temporary bitmaps. The final bitmap is then used by the Table
Probe operation to determine what rows are selected and need to be processed
for the query results. </p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajqtempbit.htm" title="The temporary bitmap is a temporary object that allows the optimizer to sequence rows based upon their row address (their row number). The bitmap can be either scanned or probed by the optimizer to satisfy different operations of the query.">Temporary bitmap</a></div>
</div>
</div>
</body>
</html>