Skip to main content

Posts

Showing posts from June, 2016

Request.ServerVariables["LOGON_USER"] returning empty ??

In Intranet application, we used to perform Windows Authentication to validate user. In ASP.NET, Request.ServerVariables["LOGON_USER"] is returning logged user name with domain value. but sometime when we are trying to access this server variable in web application it may return empty value. To resolve the issue, go to Web Site  / Web application project properties set Anonymous Authentication as Disabled and set Windows Authentication as Enabled. that's it. It will resolve the issue. Now can access all the server variables in web application

DB2 Performance Improvement Tips

1. Try to use column names instead of * in SELECT statement 2. Try to avoid IN clause 3. Try to avoid Casting, Data type conversion in WHERE clause 4. whenever joining with table, try to order the columns ( in ON Clause ) in same order of Indexed columns 5. When handling huge volume of table, approach Temporary table ( Session table) 6. Instead of using Sub query, try to use common table expression ( CTE ) 7. In WHERE clause, try to order the columns in same order of Indexed columns 8. Try to avoid CURSOR, In case if it is require go with read only CURSOR

DB2 - How to avoid IN clause

As know IN clause is one of the performance decrease operator when operating huge volume of data. Let see how to avoid IN clause and what could be alternative way to accomplish same functionality. This query contains IN clause and taking too much time SELECT column_list FROM TABLE1 WHERE Column_name in (SELECT column_name FROM TABLE2 ) To improve the performance of above query, could move the sub query statement into CTE ( Common Table Expression) and join with main query. WITH CTE AS (SELECT column_name FROM TABLE2 ) SELECT column_list FROM TABLE1 INNER JOIN CTE ON TABLE1.column_name = CTE.column_name That's it, The second query results tremendous improvement, when handling huge volume of data. Any other questions to improve the DB2 performances, please feel free to write up

Copy files and folders recursive in C#

This code written to copy files and folders recursively from one drive to another drive using C#, It could be physical storage, logical storage  or network location.  private static void Copy(string sourcePath, string targetPath)         {             foreach (string f in Directory.GetFiles(sourcePath))                 File.Copy(f, targetPath + "\\" + Path.GetFileName(f), true);             foreach (string d in Directory.GetDirectories(sourcePath))             {                 var dirName = Path.GetFileName(d);                 Directory.CreateDirectory(targetPath + "\\" + dirName);                 Copy(sourcePath + "\\" + dirName, targetPath + "\\" + dirName);           ...