• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Optimize Query for performance

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a DB2 SQL view created with below statement:

The problem I am facing is kind of strange. When we do a select * on this view, it runs slow for the first few times every new session. But then after 2 to 3 executions, the speed improves drastically and execution time reduces to 2 seconds from the initial 40 seconds.

Can someone guide on any possible optimizations:


 
 
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you are seeing is the DB2 server's internal optimizations kicking in. The more you use a statement, the more it tunes it.

There are a couple of things you can do to help. One is to set up an EXPLAIN to analyze where the "heavy lifting is done." With that information in mind, you can create indexes and re-order clauses to weed out the grossly-ineligible rows faster (since the smaller the dataset, the faster you can process it).

DB2 does also have some real-time performance measurement tools that are pretty decent.

In the case of a VIEW, also a materialized view is likely to respond better than a dynamic (plain) view. The downside to that being that the data might be stale.
 
Not looking good. I think this might be the end. Wait! Is that a tiny ad?
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic