MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

To write Better SQL statements.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
selva21
Beginner


Joined: 30 Dec 2003
Posts: 53
Topics: 31

PostPosted: Thu Jan 08, 2004 4:00 am    Post subject: To write Better SQL statements. Reply with quote

Hi,

I am in the process of consolidating tips on writing better SQL statements to improve the performance.

If you have something to add, please let me know.

Here are few.

Guideline for using a SELECT statement:

Specify only needed columns
Limit the number of rows by using predicates
Specify the FOR UPDATE clause if applicable
Specify the OPTIMIZED FOR n ROWS clause
Specify the FETCH FIRST n ROS ONLY clause
Specify the FOR FETCH ONLY clause if applicable
Avoid numeric data type conversion if required

Guidelines when choosing a data type

Use Character (CHAR) rather than varying-length data type for short columns
Use VARCHAR of VARGRAPHIC rather than LONG VARCHAR or LONG VARGRAPHIC.
Use Integer (SMALLINT, INTEGER,BIGINT) rather than floating point number (REAL or DOUBLE) or decimal (DECIMAL ) if you do not need to have the fraction part.
Use date-time (DATE,TIME,TIMESTAMP) rather than character (CHAR).
Use numeric data types rather than character.


Thanks and Regards,
A.Selvakumaran.
_________________
--------------------------------------------------------
Knowledge is power. But Imagination is more important than Knowledge. -Albert Einstein
--------------------------------------------------------
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jan 08, 2004 6:29 am    Post subject: Reply with quote

Selva,

Please search before posting. This topic had already been discussed. check this link

http://www.mvsforums.com/helpboards/viewtopic.php?p=2799

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
selva21
Beginner


Joined: 30 Dec 2003
Posts: 53
Topics: 31

PostPosted: Thu Jan 08, 2004 7:54 am    Post subject: Reply with quote

Thanks Kolusu !
_________________
--------------------------------------------------------
Knowledge is power. But Imagination is more important than Knowledge. -Albert Einstein
--------------------------------------------------------
Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 317
Topics: 50
Location: Germany

PostPosted: Thu Jan 15, 2004 1:51 pm    Post subject: Reply with quote

refer to IBM manuals, check the chapters for then EXPLAIN Command, you will find some additional tips.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group