Code Rewind
When its time to find, Hit Rewind
                 
 
 
Remember Me  
Recover Password
 
 Advanced Search
 
 Add to IE Search 
 
 
> Development => Best Practices: Database Operations
 

Available Files:
You must be signed in to download files.
You can Sign Up here if you are not a member.
Author: Adam Joseph
Level: 3
Date Posted: 13-Aug-2009 (11:18)
Last Updated: 13-Aug-2009 (11:18)
Views: 727
Favorited: 0
Votes:
  -  1 votes
Your vote:
Click to rate Click to rate Click to rate Click to rate Click to rate
(5 Stars)
Rating: 5.00 out of 5


Summary: This article will highlight few things that you could consider as part of better coding practice and for better application performance.

Introduction:
Few things that you could consider as part of better coding practice and for better application performance.

Elaboration:
Use Native Dirvers
When ever connecting to the database, make sure that you use the Native drivers for the respective databases.
 
Enable Connection Pooling
Always enable connection pooling in your application. This will save time to establish a fresh connection to the database. If any open unused connection present in the pool, by enabling Connection Pooling, application will take one open connection and use it. Ms Access database could be the only exception as it wont support this.
 
USING Statements
.Net is following OOPS concepts and hence all object must be deals in the similar and correct fashion. If you are using any object, make sure that you close/dispose them after use. Most time, developer forgets this and there will be many open objects present in the memory which is a bad thing. Hence make use of USING statement so that the object disposal will automatically taken care by the GAC.
 
Proper Table Indexes
Try to use indexes on your database tables. This will speed up the data retrieval operation.
 
Use of Stored Procedures
In old times, it was a common trend to have embedded queries (ie, having SQL code inside your application code). These days, most database supports stored procedures and hence would recommend to use Stored Procedures. If you have any database related functionalities that can be performed at backend, please do it so inside the Stored Proc itself.
 
An additional benefit to using stored procedures is that the execution plans are typically updated as part of scheduled maintenance on the DBMS.  This means that every time data is moved around on the physical disk for optimization by the server maintenance jobs, the stored procedure execution plans are automatically updated as well.  The result is that users experience continued improvement to performance rather than executed some plan that was stored years ago when they first ran the dynamic SQL statement in the application.
 
Set NoCount On at the beginning of stored procedures can reduce overhead dramatically as well if the rowcount is not required as part of processing the transaction.
 
Query Optimization
Another way to ensure good performance is to view the execution plan of any SQL statements (either dynamic or stored procedures) in SQL Server Management Studio or equivalent, to determine lock levels and possible efficiencies.  Methods like dirty reads (uncommitted or with no lock) should be used whenever possible.  Other things like making sure you are using the indexes which are set up are critical to performance.  For example, if you cast or convert a value to be different from the type that the index is set on, you lose the value of the index entirely. 

If you are facing issues with temporary data, check out this link for options - http://support.microsoft.com/default.aspx/kb/305977

Version Tracking:

Version 1.0
 
KeyWords: Generic / None (Generic / None);Generic / None,.NET Framework (Generic / None);Generic / None (Generic / None);
CR Suggested Development Articles
 
 
Most Recent Views
 
Web Session Management by Guest (08-Sep-2010 03:25)
How to use Namespace Alias Qualifier - (global) by Guest (08-Sep-2010 03:21)
About .NET Framework Versions by Guest (08-Sep-2010 03:19)
How to get details of a file extension including icon by Guest (08-Sep-2010 03:17)
What happens to the .NET Code you write? by Guest (08-Sep-2010 03:15)
 
 Messages: 0, Topics: 0. Post New Message Please login to post a message...
  View
Items per page
Message since
  TOPIC
AUTHOR
VIEWS
REPLIES
LAST POST
No messages boards...

Post New Message      
General Comment News / Info Question Answer Joke / Game Admin Answer
SEARCH ON FORUM
 
 
   
 
 
TOP USERS
 
No top users
 
 
TOP DISCUSSIONS
 
No popular discussions
 
 
SPONSORED ADS
 
 
 
 



 
Registered Members: 1621
Now Browsing: 5
 
Subscribe to newsletter
 
 

 
RapidConvert
AtHomeTution
IT2Max
TheBusinessXP
 








 
About Us  |  Contact Us   |  Privacy Policy  |  Legal Notice  |  Terms and Conditions  |  Help   |  Browse CR   |  Articles  |  Webcasts  |  Ask an Expert   |  Message Boards   |  Downloads  |  Open Arena   |  FAQ | DaniWeb | GetAHelpdesk | ProgTalk
Copyright © 2007 CodeRewind.com. All rights reserved
designed by IT2Max, INC.
 
Execution Time: 2.13 sec