Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

SQL Server memory ballooning during mass import

 
   Database Help (Home) -> Programming RSS
Next:  Linked Server, Excel - Permissions Issue  
Author Message
Mark Rae

External


Since: Feb 19, 2005
Posts: 7



(Msg. 1) Posted: Sun Feb 20, 2005 3:40 am
Post subject: SQL Server memory ballooning during mass import
Archived from groups: microsoft>public>sqlserver>programming (more info?)

Hi,

Apologies if this is not the correct newsgroup - I've also posted this
message to the microsoft.public.dotnet.framework.adonet and
microsoft.public.sqlserver.datawarehouse newsgroup...

As part of a datawarehoue application, I have a Windows service which
iterates through a mySQL DataReader (using the CoreLab native .NET provider)
and pumps the records into SQL Server 2000. There can be upwards of 300,000
rows in the mySQL DataReader. Each record in the mySQL DataReader may
represent a new record in the SQL Server database or an update of an
existing record.

The service runs quite happily consuming just under 30Mb RAM, though it does
use a fair bit of CPU, which is not surprising.

The problem (if it even is a problem...) is that the sqlserver.exe process
is ballooning out of all proportion during the part of the process where it
does the 300,000 or so database writes, almost like its caching them, or
holding them in a transaction before committing them...

However, doing a SELECT COUNT(*) on the table that the records are being
pumped into clearly shows that they're going in one by one.

Can anyone see anything glaringly obvious that I've missed from the
following code which might cause this...?

While objMySQLDR.Read ' mySQLDataReader
objSQLDS = New DataSet() ' SQL Server DataSet
objSQLDA = New SqlDataAdapter("SELECT * FROM tbl_av_content_download
WHERE ttmms_acct_id = " & pintTTMMSAcctID.ToString & "
AND tbl_cms_download_download_id = " & objMySQLDR(1).ToString,
objSQLConnection)
objSQLCommandBuilder = New SqlCommandBuilder(objSQLDA)
objSQLDA.Fill(objSQLDS, "tbl_av_content_download")
If objSQLDS.Tables(0).Rows.Count = 0 Then ' adding new row to SQL
Server
objImportRow = objSQLDS.Tables(0).NewRow ' create a blank row
For intRow As Integer = 0 to objMySQLDR.FieldCount - 1
objImportRow.Item(intRow) = objMySQLDR(intRow) ' sync the fields
Next
objSQLDS.Tables(0).Rows.Add(objImportRow) ' add the new Row to the
DataSet
Else ' updating existing row in SQL Server
objImportRow = objSQLDS.Tables(0).Rows(0) ' use the existing row
objImportRow.BeginEdit ' set it into Edit mode
For intRow As Integer = 0 to objMySQLDR.FieldCount - 1
objImportRow.Item(intRow) = objMySQLDR(intRow) ' sync the fields
Next
objImportRow.EndEdit ' set it out of Edit mode
End If
objSQLDA.Update(objSQLDS.Tables("tbl_av_content_download")) ' update the
Row object
objImportRow.AcceptChanges ' write the Row back to SQL Server
objSQLCommandBuilder.Dispose
objSQLDA.Dispose
objSQLDS.Dispose
objImportRow = Nothing
objMySQLDS.Clear
objMySQLDS.Dispose
End while
objMySQLDR.Close


Any assistance gratefully received.

Mark Rae

 >> Stay informed about: SQL Server memory ballooning during mass import 
Back to top
Login to vote
Dejan Sarka

External


Since: Mar 18, 2004
Posts: 103



(Msg. 2) Posted: Sun Feb 20, 2005 4:40 am
Post subject: Re: SQL Server memory ballooning during mass import [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Answered in .server group.

--
Dejan Sarka, SQL Server MVP
Associate Mentor
<a rel="nofollow" style='text-decoration: none;' href="http://www.SolidQualityLearning.com" target="_blank">www.SolidQualityLearning.com</a>

"Mark Rae" wrote in message

 > Hi,
 >
 > Apologies if this is not the correct newsgroup - I've also posted this
 > message to the microsoft.public.dotnet.framework.adonet and
 > microsoft.public.sqlserver.datawarehouse newsgroup...
 >
 > As part of a datawarehoue application, I have a Windows service which
 > iterates through a mySQL DataReader (using the CoreLab native .NET
provider)
 > and pumps the records into SQL Server 2000. There can be upwards of
300,000
 > rows in the mySQL DataReader. Each record in the mySQL DataReader may
 > represent a new record in the SQL Server database or an update of an
 > existing record.
 >
 > The service runs quite happily consuming just under 30Mb RAM, though it
does
 > use a fair bit of CPU, which is not surprising.
 >
 > The problem (if it even is a problem...) is that the sqlserver.exe process
 > is ballooning out of all proportion during the part of the process where
it
 > does the 300,000 or so database writes, almost like its caching them, or
 > holding them in a transaction before committing them...
 >
 > However, doing a SELECT COUNT(*) on the table that the records are being
 > pumped into clearly shows that they're going in one by one.
 >
 > Can anyone see anything glaringly obvious that I've missed from the
 > following code which might cause this...?
 >
 > While objMySQLDR.Read ' mySQLDataReader
 > objSQLDS = New DataSet() ' SQL Server DataSet
 > objSQLDA = New SqlDataAdapter("SELECT * FROM tbl_av_content_download
 > WHERE ttmms_acct_id = " & pintTTMMSAcctID.ToString & "
 > AND tbl_cms_download_download_id = " & objMySQLDR(1).ToString,
 > objSQLConnection)
 > objSQLCommandBuilder = New SqlCommandBuilder(objSQLDA)
 > objSQLDA.Fill(objSQLDS, "tbl_av_content_download")
 > If objSQLDS.Tables(0).Rows.Count = 0 Then ' adding new row to SQL
 > Server
 > objImportRow = objSQLDS.Tables(0).NewRow ' create a blank row
 > For intRow As Integer = 0 to objMySQLDR.FieldCount - 1
 > objImportRow.Item(intRow) = objMySQLDR(intRow) ' sync the
fields
 > Next
 > objSQLDS.Tables(0).Rows.Add(objImportRow) ' add the new Row to
the
 > DataSet
 > Else ' updating existing row in SQL Server
 > objImportRow = objSQLDS.Tables(0).Rows(0) ' use the existing row
 > objImportRow.BeginEdit ' set it into Edit mode
 > For intRow As Integer = 0 to objMySQLDR.FieldCount - 1
 > objImportRow.Item(intRow) = objMySQLDR(intRow) ' sync the
fields
 > Next
 > objImportRow.EndEdit ' set it out of Edit mode
 > End If
 > objSQLDA.Update(objSQLDS.Tables("tbl_av_content_download")) ' update
the
 > Row object
 > objImportRow.AcceptChanges ' write the Row back to SQL Server
 > objSQLCommandBuilder.Dispose
 > objSQLDA.Dispose
 > objSQLDS.Dispose
 > objImportRow = Nothing
 > objMySQLDS.Clear
 > objMySQLDS.Dispose
 > End while
 > objMySQLDR.Close
 >
 >
 > Any assistance gratefully received.
 >
 > Mark Rae
 >
 >

 >> Stay informed about: SQL Server memory ballooning during mass import 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
How to make MODI.Document not leak memory? I have millions.. - How to make MODI.Document not leak memory? I have millions of images to OCR but each time i OCR one it leaks memory. How to do the OCR and then clean up so that my app doesnt leak memory? MODI.Document miDoc = new MODI.Document(); ...

Mass update using calculated value - I have a mass-update going on which increases a fixed-decimal column by a user-specified percent. The query needs to ignore rows which would cause the newly calculated ddisc to overflow the column. Is there a better or more efficient way to form the...

Import network shares to sql server - hi, I just install sql server 2000 and sharepoint portal server 2003 in one box,please can you tell me how can i import my network shares into SQL to use sharepoint portal server? Thanks a lot..

Can't import some dates from Excel into Sql Server? - I have a spreadsheet that I tried to import into sql server. Some columns have dates in them. I find that some columns do appear in the resulting database table with their dates. But in one column of the database table, the dates are converted to..

can sql server import a serialized xml dataset from a vb20.. - My vb2005 app contains some tables that I created in the datasource tab which includes relationships and contraints. Everything works correctly in the app, and when the app closes I have it serialize the dataset to an xml file. When the app opens -....
   Database Help (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]