Building SQL string
Last Post 14 Dec 2012 09:20 AM by Jim Suiter. 3 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Jim Suiter
Veteran Member
Veteran Member
Posts:1565
Avatar

--
13 Dec 2012 08:26 AM
When building the SQL string does the order that the column criteria appear in the where clause make any difference in record retrieval time?  Say I have an index of Field1, Field2, and Field3.  Does it make record retrieval quicker to list those columns in the same order in the where clause?  I'm thinking not, but thought I's ask anyway.
Craig R. Lockhart
Veteran Member
Veteran Member
Posts:1167
Avatar

--
13 Dec 2012 09:29 AM
In the old days, the query engine was not as smart.  So, yes, it made a difference.  On each newer release, it makes less and less of a difference.  As of V5R4, I stopped using that as a consideration for the most part.
Harry Edmondson
Veteran Member
Veteran Member
Posts:782
Avatar

--
13 Dec 2012 07:48 PM
Jim, you may want experiment with STRDBMON/ENDDBMON. It provides quite a bit of insight as to what's happening "under the hood".

You would quickly learn if specifying key fields out of order results in an index recommendation or not.
Jim Suiter
Veteran Member
Veteran Member
Posts:1565
Avatar

--
14 Dec 2012 09:20 AM

Thanks for the info, Harry. 

In this particular situation, I am building the SQL string to make a JDBC call, so I may not be able to use this command.  The database I am connecting to is a DB2 database running on a Linux server.  There is probably similar functionality that I could use within the DB2 client that I use to directly access databasee on this server.

 

You are not authorized to post a reply.

Acceptable Use Policy