Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > DB2

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 03:27 AM
73blazer
 
Posts: n/a
Default DB2 8.2 Performance drop on Query compared to 7.1

We are migrating a customer from Version 7.1 FP3, to Version 8.2 (8.1 FP8).
For the most part, things are faster, but there is one query that is
much much slower, and it is a query that is used all the time.

select ATTR1,ATTR2,ATTR3,ATTR4 from physical.part_list
where S_PART_NUMBER like '%KJS%'

The widlcard before and after seems to be hosing it, but for this
particular piece of the application, this type of query is neccessary.

On Version 7.1, this query takes about 1.5 seconds (for 36 returns out
of 120,000 things in the table)
On Version 8.2, this query takes 13.8 seconds. (A copy of the production
database)
Most other queries are the same or faster.
I've improved my query by using

select ATTR1,ATTR2,ATTR3,ATTR4 from physical.part_list
where posstr(S_PART_NUMBER,'KJS')>0

This query is around 3.5 seconds. Much better, but still slower than
version 7.1 at 1.5 seconds

Is there anything I can do to improve that time to get it back to 1.5
seconds? What happened in DB2 8? I was reading one article that was
saying the optimization engine was changed such that 8 out of 10 queries
will be faster. Is the double wildcard one of the 2 that is slower?

DB2 8.1FP8 (8.2) on AIX 5.2 ML04 with fixes
Optimization value of the default 5

Ken
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 03:27 AM
Serge Rielau
 
Posts: n/a
Default Re: DB2 8.2 Performance drop on Query compared to 7.1

Ken,

Have you compared the explains (best db2exfmt) for the two queries?
This should be the starting point.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 03:27 AM
Mark A
 
Posts: n/a
Default Re: DB2 8.2 Performance drop on Query compared to 7.1

"73blazer" <yoyo@ma.com> wrote in message
news:LuadnWXiKe6aT8PfRVn-pQ@centurytel.net...
> We are migrating a customer from Version 7.1 FP3, to Version 8.2 (8.1
> FP8).
> For the most part, things are faster, but there is one query that is much
> much slower, and it is a query that is used all the time.
>
> select ATTR1,ATTR2,ATTR3,ATTR4 from physical.part_list
> where S_PART_NUMBER like '%KJS%'
>
> The widlcard before and after seems to be hosing it, but for this
> particular piece of the application, this type of query is neccessary.
>
> On Version 7.1, this query takes about 1.5 seconds (for 36 returns out of
> 120,000 things in the table)
> On Version 8.2, this query takes 13.8 seconds. (A copy of the production
> database)
> Most other queries are the same or faster.
> I've improved my query by using
>
> select ATTR1,ATTR2,ATTR3,ATTR4 from physical.part_list
> where posstr(S_PART_NUMBER,'KJS')>0
>
> This query is around 3.5 seconds. Much better, but still slower than
> version 7.1 at 1.5 seconds
>
> Is there anything I can do to improve that time to get it back to 1.5
> seconds? What happened in DB2 8? I was reading one article that was saying
> the optimization engine was changed such that 8 out of 10 queries will be
> faster. Is the double wildcard one of the 2 that is slower?
>
> DB2 8.1FP8 (8.2) on AIX 5.2 ML04 with fixes
> Optimization value of the default 5
>
> Ken


First, do a reorg of the table and all its indexes.

Then make sure you execute runstats and get distribution stats on key
columns and S_PART_NUMBER if it is not an indexed column.

If that does not help, you should evaluate the bufferpools and make sure the
index is in a similar buffer pool as V7 (with same objects as before). It is
possible that in your old system, the index was more likely to be resident
in the bufferpool and not flushed out by other pages.

Also, check the tablespace attributes (extent size, prefetch, etc) of the
index (assuming that S_PART_NUMBER is indexed).


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 03:27 AM
73blazer
 
Posts: n/a
Default Re: DB2 8.2 Performance drop on Query compared to 7.1

Serge Rielau wrote:

> Ken,
>
> Have you compared the explains (best db2exfmt) for the two queries?
> This should be the starting point.
>
> Cheers
> Serge
>

In looking at the exlplains for both, the optimized statment is the
same. Bufferpools match, optimization plan is the same, everything looks
ok. I don't see anything there out of wack. Just slower. The cost on 8.2
is 32458 compared to 78334 on 7.1, so shouldn't 7.1 be slower? CPU speed
is also slower on the 7.1 database. (The 8.2 database is a 4-way PWR5
AIX machine, the 7.1 database is a 4-way pwr3 machine, I run all the
statments from db2adm on the repective machine)


Is there anything special to look for in there.

Ken
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 03:27 AM
73blazer
 
Posts: n/a
Default Re: DB2 8.2 Performance drop on Query compared to 7.1

Mark A wrote:

> "73blazer" <yoyo@ma.com> wrote in message
> news:LuadnWXiKe6aT8PfRVn-pQ@centurytel.net...
>
>>We are migrating a customer from Version 7.1 FP3, to Version 8.2 (8.1
>>FP8).
>>For the most part, things are faster, but there is one query that is much
>>much slower, and it is a query that is used all the time.
>>
>>select ATTR1,ATTR2,ATTR3,ATTR4 from physical.part_list
>> where S_PART_NUMBER like '%KJS%'
>>
>>The widlcard before and after seems to be hosing it, but for this
>>particular piece of the application, this type of query is neccessary.
>>
>>On Version 7.1, this query takes about 1.5 seconds (for 36 returns out of
>>120,000 things in the table)
>>On Version 8.2, this query takes 13.8 seconds. (A copy of the production
>>database)
>>Most other queries are the same or faster.
>>I've improved my query by using
>>
>>select ATTR1,ATTR2,ATTR3,ATTR4 from physical.part_list
>> where posstr(S_PART_NUMBER,'KJS')>0
>>
>>This query is around 3.5 seconds. Much better, but still slower than
>>version 7.1 at 1.5 seconds
>>
>>Is there anything I can do to improve that time to get it back to 1.5
>>seconds? What happened in DB2 8? I was reading one article that was saying
>>the optimization engine was changed such that 8 out of 10 queries will be
>>faster. Is the double wildcard one of the 2 that is slower?
>>
>>DB2 8.1FP8 (8.2) on AIX 5.2 ML04 with fixes
>>Optimization value of the default 5
>>
>>Ken

>
>
> First, do a reorg of the table and all its indexes.
>
> Then make sure you execute runstats and get distribution stats on key
> columns and S_PART_NUMBER if it is not an indexed column.
>
> If that does not help, you should evaluate the bufferpools and make sure the
> index is in a similar buffer pool as V7 (with same objects as before). It is
> possible that in your old system, the index was more likely to be resident
> in the bufferpool and not flushed out by other pages.
>
> Also, check the tablespace attributes (extent size, prefetch, etc) of the
> index (assuming that S_PART_NUMBER is indexed).
>
>

I've done the runstats and reorg. The tablespace attributes are the
same. Bufferpools are exactly the same. indexing is the same.

Ken
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-27-2008, 03:27 AM
Mark A
 
Posts: n/a
Default Re: DB2 8.2 Performance drop on Query compared to 7.1

"73blazer" <yoyo@ma.com> wrote in message
news:buCdnWpUP7Mhc8PfRVn-sw@centurytel.net...
> I've done the runstats and reorg. The tablespace attributes are the same.
> Bufferpools are exactly the same. indexing is the same.
>
> Ken


I will assume you did the reorg first, then the runstats. Reorg and runstats
syntax is different between V7 and V8, so make sure you check the syntax and
make sure you reorg the indexes also (they automatically get reorged in
version 7).


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-27-2008, 03:27 AM
73blazer
 
Posts: n/a
Default Re: DB2 8.2 Performance drop on Query compared to 7.1

Mark A wrote:

> "73blazer" <yoyo@ma.com> wrote in message
> news:buCdnWpUP7Mhc8PfRVn-sw@centurytel.net...
>
>>I've done the runstats and reorg. The tablespace attributes are the same.
>>Bufferpools are exactly the same. indexing is the same.
>>
>>Ken

>
>
> I will assume you did the reorg first, then the runstats. Reorg and runstats
> syntax is different between V7 and V8, so make sure you check the syntax and
> make sure you reorg the indexes also (they automatically get reorged in
> version 7).
>
>

Thanks for the suggestions. Yes reorg then runstat.
I did the re-org on indexes explicitly. It wasn't done before, I didn't
know it wasn't automatically done in 8.2.
But, it didn't help. All times I give are average of 5 times run, the
avg time went up by 0.1 seconds. Still in the 14 seconds range.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-27-2008, 03:27 AM
Serge Rielau
 
Posts: n/a
Default Re: DB2 8.2 Performance drop on Query compared to 7.1

73blazer wrote:
> Mark A wrote:
>
>> "73blazer" <yoyo@ma.com> wrote in message
>> news:buCdnWpUP7Mhc8PfRVn-sw@centurytel.net...
>>
>>> I've done the runstats and reorg. The tablespace attributes are the
>>> same. Bufferpools are exactly the same. indexing is the same.
>>>
>>> Ken

>>
>>
>>
>> I will assume you did the reorg first, then the runstats. Reorg and
>> runstats syntax is different between V7 and V8, so make sure you check
>> the syntax and make sure you reorg the indexes also (they
>> automatically get reorged in version 7).
>>

> Thanks for the suggestions. Yes reorg then runstat.
> I did the re-org on indexes explicitly. It wasn't done before, I didn't
> know it wasn't automatically done in 8.2.
> But, it didn't help. All times I give are average of 5 times run, the
> avg time went up by 0.1 seconds. Still in the 14 seconds range.

Can you post the two plans?

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-27-2008, 03:27 AM
73blazer
 
Posts: n/a
Default Re: DB2 8.2 Performance drop on Query compared to 7.1

Serge Rielau wrote:

> 73blazer wrote:
>
>> Mark A wrote:
>>
>>> "73blazer" <yoyo@ma.com> wrote in message
>>> news:buCdnWpUP7Mhc8PfRVn-sw@centurytel.net...
>>>
>>>> I've done the runstats and reorg. The tablespace attributes are the
>>>> same. Bufferpools are exactly the same. indexing is the same.
>>>>
>>>> Ken
>>>
>>>
>>>
>>>
>>> I will assume you did the reorg first, then the runstats. Reorg and
>>> runstats syntax is different between V7 and V8, so make sure you
>>> check the syntax and make sure you reorg the indexes also (they
>>> automatically get reorged in version 7).
>>>

>> Thanks for the suggestions. Yes reorg then runstat.
>> I did the re-org on indexes explicitly. It wasn't done before, I
>> didn't know it wasn't automatically done in 8.2.
>> But, it didn't help. All times I give are average of 5 times run, the
>> avg time went up by 0.1 seconds. Still in the 14 seconds range.

>
> Can you post the two plans?
>
> Cheers
> Serge
>



I was watching in nmon, and it seems on my 8.2 instance that 1 CPU is
being pegged out for the duration of the query. Where on the 7.2
machine, that doesn't seem to happen, but it's hard to tell there
because the query comes back very quickly

here are the db2exfmt outputs for the queries:

DB2 Universal Database Version 7.2, 5622-044 (c) Copyright IBM Corp.
1991, 2001
Licensed Material - Program Property of IBM
IBM DATABASE 2 Explain Table Format Tool



******************** EXPLAIN INSTANCE ********************

DB2_VERSION: 07.02.0
SOURCE_NAME: SQLC2D01
SOURCE_SCHEMA: NULLID
EXPLAIN_TIME: 2005-04-14-19.10.54.089552
EXPLAIN_REQUESTER: PRDTST

Database Context:
----------------
Parallelism: None
CPU Speed: 6.691544e-07
Comm Speed: 0
Buffer Pool size: 200000
Sort Heap size: 647
Database Heap size: 3422
Lock List size: 1467
Maximum Lock List: 6
Average Applications: 50
Locks Available: 9946

Package Context:
---------------
SQL Type: Dynamic
Optimization Level: 5
Blocking: Block All Cursors
Isolation Level: Cursor Stability



---------------- STATEMENT 1 SECTION 201 ----------------
QUERYNO: 28
QUERYTAG: CLP
Statement Type: Select
Updatable: No
Deletable: No
Query Degree: 1

Original Statement:
------------------
select S_PART_NUMBER,S_TYPE
from physical.part_list
where S_PART_NUMBER like '%KEN%'


Optimized Statement:
-------------------
SELECT Q1.S_PART_NUMBER AS "S_PART_NUMBER", Q1.S_TYPE AS "S_TYPE"
FROM PHYSICAL.PART_LIST AS Q1
WHERE (Q1.S_PART_NUMBER LIKE '%KEN%')

Access Plan:
-----------
Total Cost: 78834.3
Query Degree: 1
NO TABLE INFORMATION AVAILABLE (ONLY EXPLAIN SNAPSHOT)



DB2 Universal Database Version 8.1, 5622-044 (c) Copyright IBM Corp.
1991, 2002
Licensed Material - Program Property of IBM
IBM DATABASE 2 Explain Table Format Tool



******************** EXPLAIN INSTANCE ********************

DB2_VERSION: 08.02.1
SOURCE_NAME: SQLC2E06
SOURCE_SCHEMA: NULLID
SOURCE_VERSION:
EXPLAIN_TIME: 2005-04-15-09.14.16.538703
EXPLAIN_REQUESTER: DB2864

Database Context:
----------------
Parallelism: None
CPU Speed: 6.723442e-07
Comm Speed: 100
Buffer Pool size: 200000
Sort Heap size: 647
Database Heap size: 3422
Lock List size: 1467
Maximum Lock List: 6
Average Applications: 1
Locks Available: 5633

Package Context:
---------------
SQL Type: Dynamic
Optimization Level: 5
Blocking: Block All Cursors
Isolation Level: Cursor Stability



---------------- STATEMENT 1 SECTION 201 ----------------
QUERYNO: 1
QUERYTAG: CLP
Statement Type: Select
Updatable: No
Deletable: No
Query Degree: 1

Original Statement:
------------------
select S_PART_NUMBER,S_TYPE
from physical.part_list
where S_PART_NUMBER like '%KEN%'


Optimized Statement:
-------------------
SELECT Q1.S_PART_NUMBER AS "S_PART_NUMBER", Q1.S_TYPE AS "S_TYPE"
FROM PHYSICAL.PART_LIST AS Q1
WHERE (Q1.S_PART_NUMBER LIKE '%KEN%')

Access Plan:
-----------
Total Cost: 28265.9
Query Degree: 1
NO TABLE INFORMATION AVAILABLE (ONLY EXPLAIN SNAPSHOT)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-27-2008, 03:27 AM
73blazer
 
Posts: n/a
Default Re: DB2 8.2 Performance drop on Query compared to 7.1

Serge Rielau wrote:

> 73blazer wrote:
>
>> Mark A wrote:
>>
>>> "73blazer" <yoyo@ma.com> wrote in message
>>> news:buCdnWpUP7Mhc8PfRVn-sw@centurytel.net...
>>>
>>>> I've done the runstats and reorg. The tablespace attributes are the
>>>> same. Bufferpools are exactly the same. indexing is the same.
>>>>
>>>> Ken
>>>
>>>
>>>
>>>
>>> I will assume you did the reorg first, then the runstats. Reorg and
>>> runstats syntax is different between V7 and V8, so make sure you
>>> check the syntax and make sure you reorg the indexes also (they
>>> automatically get reorged in version 7).
>>>

>> Thanks for the suggestions. Yes reorg then runstat.
>> I did the re-org on indexes explicitly. It wasn't done before, I
>> didn't know it wasn't automatically done in 8.2.
>> But, it didn't help. All times I give are average of 5 times run, the
>> avg time went up by 0.1 seconds. Still in the 14 seconds range.

>
> Can you post the two plans?
>
> Cheers
> Serge
>

I am appreciating all the help.
It seems with all the table re-orgs and index re-orgs I've done now (I
didn't realize indexes are no longer done automatically in 8, so I did
them now) that my posstr method is down to .35 seconds. The %STRING%
method is still 11.7 seconds.
0.35, I'm very happy. But still wondering why the like '%STRING%' is
drastically slower on 8.

Ken
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:41 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538