tags:

views:

45

answers:

3

Hi,

In a single webmethod in .net webservice there are 4 times DB hit (for different tables), apart from using stored procedures, is there any means which i can follow to reduce the db hit?

+3  A: 

Write a single query that collects all the data you require.

There is almost always a way to do one query.

Select A.A1, A.A2, A.A3, B.B1, B.B2, B.B3
From TableB B
    Inner Join (
        Select A1, A2, A3
        From TableA
        Where A1 = @Id
    ) A On B.B1 = A.A2
ChaosPandion
The second select statement has a parameter which has to come from I query, any other approach?
Karthick
@Karthick - See update.
ChaosPandion
Thanks ChaosPandion, for ex:Select A1.Column1 from table1 where userid='Karthick';Select A2.Column1 from table2 where A2.Column=output of first query;Select A2.Column1 from table2 where A2.Column=A1.Column1How do we can approach to make this to a single db hit?
Karthick
+2  A: 

Look into ASP.Net Data Caching.

You can keep your result set for the duration of your request, and even longer, reducing your database round trips.

kervin
+1  A: 

Use caching to store values from the database in server memory. There are many options here, depending on what you need.

Rune Grimstad