---
title: "The Essential Guide to 8 Index Access Paths in DB2"
description: "DB2 will use these index access paths. As said in IBM DB2 Manual: The access path for an SQL statement specifies how Db2 accesses the data that the query specifies. It specifies the indexes and tables..."
url: https://srinimf.com/2023/04/15/8-index-access-paths-db2-uses-for-sql-performance1-of-2/
date: 2023-04-15
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2015/09/pexels-photo-2789779.jpeg?fit=1880%2C1253&ssl=1
categories: ["DB2"]
tags: ["DB2 Index", "DB2 index access paths"]
type: post
lang: en
---

# The Essential Guide to 8 Index Access Paths in DB2

DB2 will use these index access paths. As said in IBM DB2 Manual: The access path for an SQL statement specifies how Db2 accesses the data that the query specifies. It specifies the indexes and tables that are accessed, [the access methods that are used](https://www.ibm.com/docs/en/db2-for-zos/12?topic=performance-managing-query-access-paths), and the order in which objects are accessed.

Related[DB2 V11- Analytics and Bigdata Features](https://srinimf.com/2014/10/28/db2-v11-analytics-and-bigdata-features/)

## **DB2 access path types**

Here are the 8 top Index access paths.

**Matching-index scan (MATCHCOLS > 0)**

```
SELECT * FROM T
  WHERE C1=1 AND C2>1
    AND C3=1;
```

**Index screening**

```
SELECT * FROM T
  WHERE C1 = 1
    AND C3 > 0 AND C4 = 2
    AND C5 = 8;
```

**Nonmatching-index scan (ACCESSTYPE = I and MATCHCOLS = 0)**

```
--When index screening predicates exist
In that case, not all of the data pages are accessed.
--When the clause OPTIMIZE FOR n ROWS is used
That clause can sometimes favor a nonmatching index, especially if the index gives the ordering of the ORDER BY clause or GROUP BY clause.
--When more than one table exists in a non-segmented table space
In that case, a table space scan reads irrelevant rows. By accessing the rows through the nonmatching index, fewer rows are read.
```

**IN-list index scan (ACCESSTYPE = N)**

```
SELECT * FROM T
  WHERE C1=1 AND C2 IN (1,2,3)
    AND C3>0 AND C4<100;
```

Advertisements

**Multiple-index access (ACCESSTYPE is M, MX, MI, or MU)**

```
SELECT * FROM EMP
   WHERE (AGE = 34) OR
         (AGE = 40 AND JOB = 'MANAGER');
```

**One-fetch access (ACCESSTYPE = I1)**

```
SELECT MIN(C1) FROM T;
SELECT MIN(C1) FROM T WHERE C1>5;
SELECT MIN(C1) FROM T WHERE C1>5 AND C1<10;
SELECT MIN(C2) FROM T WHERE C1=5;
SELECT MAX(C1) FROM T;
SELECT MAX(C2) FROM T WHERE C1=5 AND C2<10;
SELECT MAX(C2) FROM T WHERE C1=5 AND C2>5 AND C2<10;
SELECT MAX(C2) FROM T WHERE C1=5 AND C2 BETWEEN 5 AND 10;
```

**Index-only access (INDEXONLY = Y)**

```
SELECT C1, C2 FROM T WHERE C1 > 0;
SELECT C1, C2 FROM T;
SELECT COUNT(*) FROM T WHERE C1 = 1;
```

**Equal unique index (MATCHCOLS = number of index columns)**

```
Unique Index1: (C1, C2)
Unique Index2: (C2, C1, C3)
 
SELECT C3 FROM T
  WHERE C1 = 1 AND C2 = 5;
```

Related

- [DB2 Access Path: What is New Hashing Technique](https://srinimf.com/2016/03/30/how-hash-access-is-faster-than-index-access-in-db2/)DateMarch 30, 2016
- [DB2 in simple way: what is index only access](https://srinimf.com/2016/09/17/db2-in-simple-way-what-is-index-only-access/)DateSeptember 17, 2016
- [DB2 Index Vs. Hash Scan: Top Differences](https://srinimf.com/2018/11/01/db2-top-differences-read-on-index-vs-hashing/)DateNovember 1, 2018

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2023%2F04%2F15%2F8-index-access-paths-db2-uses-for-sql-performance1-of-2%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2015%2F09%2Fpexels-photo-2789779.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=The%20Essential%20Guide%20to%208%20Index%20Access%20Paths%20in%20DB2)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2023/04/15/8-index-access-paths-db2-uses-for-sql-performance1-of-2/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2023/04/15/8-index-access-paths-db2-uses-for-sql-performance1-of-2/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2023/04/15/8-index-access-paths-db2-uses-for-sql-performance1-of-2/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2023/04/15/8-index-access-paths-db2-uses-for-sql-performance1-of-2/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20The%20Essential%20Guide%20to%208%20Index%20Access%20Paths%20in%20DB2&body=https%3A%2F%2Fsrinimf.com%2F2023%2F04%2F15%2F8-index-access-paths-db2-uses-for-sql-performance1-of-2%2F&share=email)
-

### Like this:

Like Loading…
