Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to execute database queries from server (not from client machine).
so i have used WCF service which execute database queries on server and reruns the result.
initially it works fine but sometimes its response gets worst.How i can improved performance of my application using WCF service or web service can solved my problem.
or any other way.
please help..
Posted
Updated 14-Dec-12 5:44am
v2

1 solution

First things first, if your WCF service is IIS hosted, move it so it's self hosted. Hosting WCF services in IIS means you get all the latency of of IIS worker process management. I'm also assuming your database is SQL?

http://msdn.microsoft.com/en-us/library/ms731758.aspx[^]

With self hosted a good grasp of WCF concurrency and throttling is required. So read this.

WCF Concurrency (Single, Multiple, and Reentrant) and Throttling[^]

Beyond that, with out a better understanding of your code and database it will be difficult to advise you on the exact cause of the latency. That said, please don't post all your code.

First thing I'd look for are locks in the database. If a row is locked it can hold up an SQL query until unlocked.

The following describes how to check for record locks.

http://stackoverflow.com/questions/694581/how-to-check-which-locks-are-held-on-a-table[^]

You can instruct SQL queries to read over locked records, returning the old value rather than the value waiting to be written to the database using the NOLOCK hint.

http://www.mssqltips.com/sqlservertip/2470/understanding-the-sql-server-nolock-hint/[^]

It could also be that queries in SQL are not optimised well for specific parameter sets. You can look at this using SQL's Execution Plan

SQL Tuning Tutorial - Understanding a Database Execution Plan (1)[^]

Or it could be as simple as your indexes are a little messed up and you need to update your database statistics using sp_updatestats

http://msdn.microsoft.com/en-us/library/ms173804.aspx[^]

If IIS isn't causing your problem and your database isn't causing your problem then by a process of elimination, it must be your code.

A tool which should be in every developers tool kit is Redgate's Ant's Profiler. This tool will profile each line of your code whilst it executes in visual studio. The report will then show how long was spent on each line of code and as such where the slowest parts of your code are.

Redgate offer a free trial of the software.

http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900