• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
  • Carey Brown
  • salvin francis
  • Piet Souris

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: 23263
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.
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic