IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Improve the performance of SELECT query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rahul_desai29

New User


Joined: 15 Mar 2006
Posts: 10
Location: fl;jds

PostPosted: Tue Mar 21, 2006 11:55 am
Reply with quote



SELECT * it is running very slow,how you will make it faster?
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Tue Mar 21, 2006 12:58 pm
Reply with quote

Quote:
SELECT * it is running very slow,how you will make it faster?

By coding only your columns of interest.

Regards,
Priyesh.
Back to top
View user's profile Send private message
KS

New User


Joined: 28 Feb 2006
Posts: 91
Location: Chennai

PostPosted: Wed Mar 22, 2006 12:14 pm
Reply with quote

Hi,
It is not the correct standard to give a select a query with *.This statement will result in excessive I/O overhead.
1. Instead of '*' , give the column names on which u need to select
2. Give necessary where clause
3. If u r tring to fetch rows from a larger db , thenuse FETCH FIRST 100 ROWS ONLY;
ex-
SELECT TRANS_NO , ST_DATE FROM EMPLOYEE.TABLE1
WHERE TRANS_NO = 7458959
ORDER BY TRANS_NO DESC
FETCH FIRST 100 ROWS ONLY ;

Thanks,
Ks
Back to top
View user's profile Send private message
Gautam512

Active User


Joined: 05 Oct 2005
Posts: 308
Location: Vizag / US

PostPosted: Wed Mar 22, 2006 3:47 pm
Reply with quote

i totally accept what KuttiSatha said,

Select * always increases the I/O overhead.

Better to give the required column names.

One more important thing which increases the efficiency is,

for every column in a table there will be assigned indices (order of preference) if u use the same order for the column selected in the select query u'll surely increase the efficiency.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Wed Mar 22, 2006 4:15 pm
Reply with quote

You may also want to code "FOR FETCH ONLY" to improve preformance, in case your query is read-only.

Regards,
Priyesh.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts exploiting Z16 performance PL/I & Assembler 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
Search our Forums:

Back to Top