• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Optimize Query for performance

 
Ranch Hand
Posts: 160
  • 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: 27885
198
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic