I have a VB web application that reads from a CSV file which contains about 300,000++ lines. The application will read line-by-line and for each line, it will query a table in a sql server database which contains about 100,000++ records and based on the results of the query, the application will do something else. sqlservr.exe maxes out memory consumption in my development machine of 4GB.
So I created a simple application to test the performance of sql server in terms of loop query.
Dim Connection As New SqlConnection(ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString)
Dim Command As New SqlCommand("", Connection)
Connection.Open()
For i As Integer = 0 To 20000
Command.CommandText = "SELECT CustomerID FROM Customer WHERE CustomerID = " & i
Command.ExecuteScalar()
Next
Connection.Close()
Every time this code is executed, sqlservr.exe will take up an additional 100MB++ of memory and it's not releasing it back even though after the code has finished executing.
Is this normal? Is there any way to mitigate this effect?