Skip to main content

Posts

Showing posts from May, 2012

Performance Tuning with SQL Server

In continuation of last post of SQL Server: Query Optimization And SQL Tuning , here I write some more tips related to performance tuning. Look at the DB Schema and see if it makes sense Most often, Databases have bad designs and are not normalized. This can greatly affect the speed of your Database. As a general case, learn the 3 Normal Forms and apply them at all times. The normal forms above 3 rd  Normal Form are often called de-normalization forms but what this really means is that they break some rules to make the Database faster. What I suggest is to stick to the 3 rd  normal form except if you are a DBA (which means you know subsequent forms and know what you're doing). Normalization after the 3 rd  NF is often done at a later time, not during design. There are several problem one can face while working with SQL Server and several strategies used for tuning the performance in SQL Server: Problem: Low Memory Condition detected and Low Hit Cache Rate resul

Delete All Files in C#

In last example I have shown how to Get files in C#, if you want to read check here , In this examples I’ll show how to delete all files (*.*) from a directory in C#. First, you need to get the list of file names from the specified directory (using static method Directory.Get­Files . Then delete all files from the list, here I'm using same directory that I used in last example. Delete all files String [] files = System.IO. Directory .GetFiles( @"c:\Sandeep\" ); foreach ( String file in files)     System.IO. File .Delete(file);   Delete all files (in one line) To delete all files using one code line, you can use Array.ForEach with combination of anonymous method.    Array .ForEach(System.IO. Directory .GetFiles( @"c:\Sandeep\" ),                 delegate ( String path) { System.IO. File .Delete(path); });

Get Files from Directory in C#

Here I am writing an example which shows how to get list of file names from a directory (including its subdirectories), and also demonstrate how one can filter the list by extension. I have one directory(Folder) named as Sandeep under D drive(ref. fig.1), which have three files and one subdirectory Test Dir.  fig.1 Test Dir also contains one file(ref. fig.2) fig.2 To get file names from the specified directory, we need to use static method Directory.Get­Files Get all files from directory To get all files from directory, method Directory.GetFiles returns string array with files names (full paths). String [] files = System.IO. Directory .GetFiles( @"c:\Sandeep\" );        // returned files:        // "D:\Sandeep\abc.txt"        // "D:\Sandeep\Test_123.xls"        // "D:\Sandeep\Test_1222.doc"   Get files from directory (with specified extension) You can specify search pattern, inside your directory. You can u

Avoid the cache effect for Ajax calls in Internet Explorer(IE) browser

If you use a GET method to send an asynchronous request to your server side code, Internet Explorer will cache locally your GET request, so obviously you won't get the latest result in your response.  Firefox and Chrome doesn't seem to have this issue. To resolve or handle cache effect issue for Ajax call: ·          Either use POST method instead of GET ·          Or add some random value to your GET request so instead of using like this from client side, var getUrl = 'GetUser.aspx?username=sandeep' use this: var getUrl = 'GetUser.aspx?username=sandeep'   + ' &rdm=' + new Date().getTime(); This will force IE to show a fresh version of your request all the time.

SQL Server: Query Optimization And SQL Tuning

To get better and time efficient result from SQL server, one need to be careful while designing DB and working with Queries. SQL Statements are used to retrieve data from the database. We can get same results by writing different sql queries. But use of the best query is important when performance is considered. So one need to write SQL query with performance and requirement in mind.  Here I am sharing some performance optimization techniques from my experience. SQL Tuning/SQL Optimization Techniques: Every Table should have primary key, if primary column is of integer type, then it should have Identity set to true. Table should have appropriate amount of non-clustered index, Non-clustered index should be created on columns of table based on query which is running  Following priority order should be followed when any index is created a) WHERE clause, b) JOIN clause, c) ORDER BY clause, d) SELECT clause Always use the actual columns names in