Thread: DB2

EXPLAIN says tablespace scan - index looks perfect on paper

Started by Omar • user4 replies189 viewsLast activity 2 weeks ago
Post #1
1 votes
Omar
Reputation
155
Posts: 12
Joined: Jan 7, 2025, 10:05 AM
Posted: Jul 25, 2026, 11:07 AM

Predicate is on the leading column of a unique index. RUNSTATS were this week. EXPLAIN still wants a tablespace scan on a 20M row table.

Host variable is typed differently than the column (CHAR vs VARCHAR). Could that alone kill matching?

Post #2
0 votes
Elena
Reputation
391
Posts: 19
Joined: Apr 18, 2024, 9:30 AM
Posted: Jul 25, 2026, 1:07 PM

Yes. Type mismatch can disable matching index use. Align the host variable with the column definition. Also check for residual predicates (stage 2) hiding in the WHERE.

Post #3
0 votes
Sandra
Reputation
198
Posts: 17
Joined: Oct 15, 2024, 8:30 AM
Posted: Jul 25, 2026, 5:07 PM

And make sure you are looking at the plan that is actually bound in that environment. We wasted a day tuning a package that prod was not running.

Post #4
1 votes
Omar
Reputation
155
Posts: 12
Joined: Jan 7, 2025, 10:05 AM
Posted: Jul 26, 2026, 3:07 PM

Host var was VARCHAR, column CHAR. Fixed the declaration, rebound, index match. Feels silly in hindsight.

You must be signed in to reply to this thread