Hi, all.
I had a question about optimizing the insertion of many records into a SQL Server Compact Edition database. Basically, I'm grabbing a set of data from an Oracle database using an OracleDataReader object and adding it to the SSCE database. I'm looping through the items in my datareader object (dr) as follows:
while (dr.Read())
{
string studio = dr["STUDIO"].ToString().Trim();
string view_dt = dr["VIEW_DT"].ToString().Trim();
string series = dr["SERIES"].ToString().Trim();
string clip_or_episode = dr["CLIP_OR_EPISODE"].ToString().Trim();
string imps_estimated = dr["IMPS_ESTIMATED"].ToString().Trim();
string video_title = dr["VIDEO_TITLE"].ToString().Trim();
string asset_id = dr["ASSET_ID"].ToString().Trim();
string series_cat = dr["SERIES_CAT"].ToString().Trim();
string content_start_cnt = dr["CONTENT_START_CNT"].ToString().Trim();
dwAssetsTableAdapter.Insert(studio, DateTime.Parse(view_dt), series, clip_or_episode, long.Parse(imps_estimated), video_title, long.Parse(asset_id), series_cat, int.Parse(content_start_cnt));
}
This takes about 3.5 minutes for ~3k records, which is painfully slow since I will probably need to process tens of thousands at a time. What can I do to make this go faster? Shouldn't this take seconds? Also, I'm a bit of a neophyte when it comes to C# and programming in general, so some generalized code examples would be greatly appreciated with any advice. Thanks in advance for your help!
Loading
RajPosted Oct 6, 2009, 4:40 PM
Also, as a secondary issue, I tried connecting to my database via a connection string instead of through tableAdapters. However, the connection string can only be 128 characters in length and my database is buried deep in my directory structure (moved there by Visual Studio Express). Has anyone come across this issue and found a way around it? Thanks!
Roei BarPosted Oct 6, 2009, 3:30 PM
or you can do a bulk insert to a temporary table and run the insert SP on each row
this will be much better in performance