Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

How to optimize the below query to give fast results  RSS feed

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I am not good at DB side, so i would like to take your help. Below query taking so much time to featch the results. Can anyone show me the solution about how to optimise it.

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does this mean? "PUB.PUBLSEQ LIKE '%%%%%J'"
and what is the difference from this? "PUB.PUBLSEQ LIKE '%J'"

You can use only one "%" that means any and many times. You don't need to repeat it. It is not wrong but looks weird.

For optimizing your query:
1) take an explain plan for your query and focus on high costs and full table accesses.
2) using functions on where clause prevents index usage, if function usage is dispensable get rid of it.
3) adding indexes on columns used for joins may help, but it should be analyzed. Query optimization and sql tuning does not mean adding index on all join columns. A dba may help you on index analysis.

Regards,
Fatih.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!