SQL Server stored procedure runs fast in SSMS and slow in C# windows form application

  • Thread starter Thread starter Sagar Kerlekar, India
  • Start date Start date
S

Sagar Kerlekar, India

Guest
Hi,

I have an C# winform application with sql express db,

I have table contains 20 columns and 2 lacks records, table having 6 index 1 is clustered index and 5 are non clustered index.

in 5 index 3 columns are varchar datatype and 1 column is bit and 1 is numeric datatype.

My Application scenario is

we have 2 Application and PC both the pc running different applications and accessed single db located at PC 1-

both the applications running continuously and hit on db for "UPDATE" records and sometimes "SELECT" some record.

We have no concern about update statement, but whenever application hit select query then sometimes application takes more time than normal, I have very much concern about the select statement result. below is my query which is called from store procedure.

SELECT Count(PrimaryKey) as CNT From Tabel where Col1 ="AAAAAAAA" and (Col2 =0 OR Col2 is null) and Col3 =0

Most of the times the SP given result in 1 or 2 millisecond but sometimes it takes 45,60, 90,189, 260 e.t.c millisecond, which not useful for my applications

I am facing this issue at second PC which is remotely access DB though LAN.

The execution time has been confirmed by application logs which maintained by my application and through SQL profiler.

My expected result is in 1 to 30 millisecond not more than 30,

Please help me on this for getting consistent time result.

Thank you so much in advance.


Thanks,

Sagar Kerlekar.

Continue reading...
 
Back
Top