views:

105

answers:

1

I'm getting this error:

There is insufficient system memory in resource pool 'default' to run this query.

I'm just running 100,000 simple insert statements as shown below. I got the error approx on the 85,000th insert.

This is a demo for a class I'm taking...

use sampleautogrow

INSERT INTO SampleData VALUES ('fazgypvlhl2svnh1t5di','8l8hzn95y5v20nlmoyzpq17v68chfjh9tbj496t4',1)
INSERT INTO SampleData VALUES ('31t7phmjs7rcwi7d3ctg','852wm0l8zvd7k5vuemo16e67ydk9cq6rzp0f0sbs',2)
INSERT INTO SampleData VALUES ('w3dtv4wsm3ho9l3073o1','udn28w25dogxb9ttwyqeieuz6almxg53a1ki72dq',1)
INSERT INTO SampleData VALUES ('23u5uod07zilskyuhd7d','dopw0c76z7h1mu4p1hrfe8d7ei1z2rpwsffvk3pi',3)

Thanks In Advance, Jim M

Update: Just noticed something very interesting. I created another database, forgot to create the SampleData table. I ran the query to add the 100,000 rows, and it got the out of memory error before it even complained that the table didn't exist. Thus, I'm guessing it is running out of memory just trying to "read in" my 100,000 lines?

+6  A: 

You have 100.000 insert statements in one single batch request? Your server needs more RAM just to parse the request. Buy more RAM, upgrade to x64 or reduce the size of single batches sent to the server. Ie. sprinkle a GO every now and there in the .sql file.

Remus Rusanu
If 1000 inserts cause no problem, why do 100,000 cause a problem? Does it have something to do with transactions? Why would adding "GO" statements help?
Jim Messler
See my update in original question above.
Jim Messler
when you send 100k INSERT statements in one batch the server will initially see about 1 mil. characters of 'stuff'. It doesn't know what's inside, it could be all dots and spaces. It has to be parsed first, and T-SQL is parsed in batches, not in lines (unlike, say Basic is). That parsing consumes memory and this is the error you see. When you've tried with an unexisting table, the server did not even reach the point when it would check if the table exists, since that occurs during compile time not during parse time. It has to parse the entire batch first, and that cannot do.
Remus Rusanu