An ODBS script agent hangs if the result is very big (160 k)

I have a very simple ODBC script agent that gets data from SQL and either creates or updates documents in Notes. The query results in a bit result set (1657413) rows. The problem is my client is hanging after i run the agent. I see Not responding in the Task Manager. If i modify the query to get get only top 10 rows, the agent runs fine. I am confused as to why this is hapenning. Is it due to memory constraints or is there a limitation on the size of result set that notes ca handle? Any help would be greatly appreciated.

Here is the agent code:

"Dim s As New notessession

Dim db As notesdatabase	

Dim doc As notesdocument

Dim NewDoc As NotesDocument

Dim DocCount As Long

Dim dc As NotesDocumentCollection

Dim CheckView As notesView



Dim Count 		As			Long	

Dim	Con			As  		New ODBCConnection	

Dim	Res			As 		New ODBCResultSet	

Dim Qry 			As 		New ODBCQuery



Dim FromDate 	As 		Variant

Dim ToDate 		As 		Variant

Dim MaxRows   As 		Long





Set db = s.CurrentDatabase



ServerName = Db.Server ' Storing the servername as we will be looking up the E-mail from Countrywide Directory on same server.

Set  CheckView = db.getView("Demand Check")          

Call checkView.Refresh



Set Con = New ODBCConnection 

con.SilentMode = True



Call con.ConnectTo("TrackAutoCreate","nttracker",  "nt@tracker") 

Set qry.Connection = con

Set res.Query 		= qry



Qry1$ =		" select   *  from Staging.Marketing.FSLPortLeadsForUpload where LeadType ='L4'" 

Qry1$ = Qry1$ + "  and ProcessStatus is Null order by LeadPrioritySequence " 



Qry.SQL = Qry1$

Call res.Execute

con.Disconnect

Exit Sub"

Please ignore the earlier post which is the same issue, but i did not describe it properly. My appologies on that.

Subject: an ODBS script agent hangs if the result is very big (160 k)

The number you gave isn’t 160K, it’s 1.6M. That’s going to take a very, very long time to process and will hang your Notes client while it runs. It will show Not Responding, but if you check the VM and CPU use you will see it’s still churning away.