C
Christopher Fairbairn
Hi,
I am quite new to the use of the compact framework for application
development on primarily Pocket PC 2003 and (now with the emergance of
suitable devices) Pocket PC 2005 based PDAs. I have however spent a long
time (many years) doing development using unmanaged C++ code in such an
environment.
As part of evaluating a switch to C# development on the Compact Framework
for a new version of my application, I am evaluating the use of SQLCE for
local database functionality. At present I am using another thirdparty
database technology and I am considering switching to SQLCE at the same time
I make the switch to C#.
At present I have made a proof of concept application which performs some of
the basic functions required for my application in order to evaluate
concerns over speed and development effort etc.
When this application is using a CDMA data connection it can transfer 21,000
records worth of "static data" (lookup tables of business specific data used
in various parts of the handheld UI) from the server to the mobile handheld
in approximatly 20 seconds.
My problem is that it is then taking approximatly the next 10 minutes using
SqlCeCommand's ExecuteNonQuery() to perform the nesscary INSERT and/or
UPDATE statements in order to place this data into the SQLCE database. I
would like to attempt to decrease this timeframe, although by itself an
insert/update every 28ms or so on average isn't too bad I guess if you only
need to do an insert of one or two records.
Does anyone have any performance related tips/advice in order to attempt to
increase the performance of inserting data into the SQLCE database? Not
having much experience with SQLCE I am not too sure about how to fine tune
it's performance etc. Is there any mechanism/api targeted specifically for
bulk data transfers? Things I have tried include:
1) Reusing SqlCeCommand objects (I have two command objects for each table
of static data, one doing a parameterised insert and one doing a
parameterised update) rather than creating new SqlCeCommand objects for each
of the 21,000 rows.
2) Using parameterised statements and calling Prepare() on them before
entering the loop which will generate 21,000 new rows. These loops update
the parameter values and then re-invoke ExecuteNonQuery() in order to
execute the prepared statement again.
3) When specifying the parameters for the statements I explictly set their
datatypes and max lengths etc.
4) The data comming from the server tells me if I need to do an update vs an
insert. Hence I don't need to do a query on the handheld database for each
row to detect what type of SQL statement I must use for a given row.
Any ideas, tips, or SQLCE performance numbers greatly appreciated.
Thanks,
Christopher Fairbairn
I am quite new to the use of the compact framework for application
development on primarily Pocket PC 2003 and (now with the emergance of
suitable devices) Pocket PC 2005 based PDAs. I have however spent a long
time (many years) doing development using unmanaged C++ code in such an
environment.
As part of evaluating a switch to C# development on the Compact Framework
for a new version of my application, I am evaluating the use of SQLCE for
local database functionality. At present I am using another thirdparty
database technology and I am considering switching to SQLCE at the same time
I make the switch to C#.
At present I have made a proof of concept application which performs some of
the basic functions required for my application in order to evaluate
concerns over speed and development effort etc.
When this application is using a CDMA data connection it can transfer 21,000
records worth of "static data" (lookup tables of business specific data used
in various parts of the handheld UI) from the server to the mobile handheld
in approximatly 20 seconds.
My problem is that it is then taking approximatly the next 10 minutes using
SqlCeCommand's ExecuteNonQuery() to perform the nesscary INSERT and/or
UPDATE statements in order to place this data into the SQLCE database. I
would like to attempt to decrease this timeframe, although by itself an
insert/update every 28ms or so on average isn't too bad I guess if you only
need to do an insert of one or two records.
Does anyone have any performance related tips/advice in order to attempt to
increase the performance of inserting data into the SQLCE database? Not
having much experience with SQLCE I am not too sure about how to fine tune
it's performance etc. Is there any mechanism/api targeted specifically for
bulk data transfers? Things I have tried include:
1) Reusing SqlCeCommand objects (I have two command objects for each table
of static data, one doing a parameterised insert and one doing a
parameterised update) rather than creating new SqlCeCommand objects for each
of the 21,000 rows.
2) Using parameterised statements and calling Prepare() on them before
entering the loop which will generate 21,000 new rows. These loops update
the parameter values and then re-invoke ExecuteNonQuery() in order to
execute the prepared statement again.
3) When specifying the parameters for the statements I explictly set their
datatypes and max lengths etc.
4) The data comming from the server tells me if I need to do an update vs an
insert. Hence I don't need to do a query on the handheld database for each
row to detect what type of SQL statement I must use for a given row.
Any ideas, tips, or SQLCE performance numbers greatly appreciated.
Thanks,
Christopher Fairbairn