Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Working with an internal project. I am using following technologies based on requirements.

1) VS 2012.
2) SQL Compact 4.0
3) .net 2.0 frame.

When i am trying to query which retrieves 592 rows is taking 20 seconds. While it is taking 1.7 minutes to retrieve 2472 rows. It is really slow. Can any body help me to resolve this performance issue.

Following is DB Structure. [^]


1) LCD table with 1103 rows.
2) LCDHcpcs with 17807 rows.
3) HcpcsRef with 16207 rows.
4) LcdICD10 with 356441 rows
5) Icd10Ref with 69825 rows.

I am trying to use following code and query.

C#
public System.Data.SqlServerCe.SqlCeResultSet ExecuteAndGetSqlCEResultsetViewOption()
        {
		System.Data.SqlServerCe.SqlCeConnection conn = DAL.GetSqlCEConnection();
		stringStrQuery = "SELECT DISTINCT ICD10Ref.ICD10ID as [Icd 10], ICD10Ref.Description as Description FROM Lcd INNER JOIN LCDIcd10 ON " +
                "Lcd.LcdID = LCDIcd10.LCD AND Lcd.Version = LCDIcd10.LcdVersion INNER JOIN ICD10Ref ON LCDIcd10.ICD10ID = ICD10Ref.ICD10ID AND " +
                "LCDIcd10.ICD10Version = ICD10Ref.ICD10Version WHERE (Lcd.LcdID = 33621)"
            	
		System.Data.SqlServerCe.SqlCeResultSet view = null;

            using (System.Data.SqlServerCe.SqlCeCommand comm = new System.Data.SqlServerCe.SqlCeCommand(strQuery, conn))
            {
                view = comm.ExecuteResultSet(System.Data.SqlServerCe.ResultSetOptions.Scrollable);
            }
            conn.Close();
            return view;
        }


What I have tried:

public System.Data.SqlServerCe.SqlCeResultSet ExecuteAndGetSqlCEResultsetViewOption()
{
System.Data.SqlServerCe.SqlCeConnection conn = DAL.GetSqlCEConnection();
stringStrQuery = "SELECT DISTINCT ICD10Ref.ICD10ID as [Icd 10], ICD10Ref.Description as Description FROM Lcd INNER JOIN LCDIcd10 ON " +
"Lcd.LcdID = LCDIcd10.LCD AND Lcd.Version = LCDIcd10.LcdVersion INNER JOIN ICD10Ref ON LCDIcd10.ICD10ID = ICD10Ref.ICD10ID AND " +
"LCDIcd10.ICD10Version = ICD10Ref.ICD10Version WHERE (Lcd.LcdID = 33621)"

System.Data.SqlServerCe.SqlCeResultSet view = null;

using (System.Data.SqlServerCe.SqlCeCommand comm = new System.Data.SqlServerCe.SqlCeCommand(strQuery, conn))
{
view = comm.ExecuteResultSet(System.Data.SqlServerCe.ResultSetOptions.Scrollable);
}
conn.Close();
return view;
}
Posted
Updated 7-Jun-16 17:20pm

1 solution

Look at tuning the Query through adding indexes based on the execution plan.
Depending on what version of SQL Compact you are using you can use SQL Management Studio (pre v4.0) or Visual Studio 2010 Sp1 Transact SQL Editor.
The following MS Technet link should help you with getting a handle on performance tuning; Query Performance Tuning (SQL Server Compact)[^]

Kind Regards
 
Share this answer
 
Comments
jame01 8-Jun-16 18:58pm    
run your program as administrator,
or use sqlite it quite fast ....

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