How do I troubleshoot this CLR error in SQL Server (64-bit) spatial

Posted on 2016-09-08
Last Modified: 2016-09-26
I have the following query:

    Insert into PropertyTractsTemp
    		P.field1 as field1 , 
    		P.field2 as field2, 
    		P.field3 as field3, 
    		P.field4 as field4, 
    		P.field5 as field5
    	join BH_EDW.dbo.REF_GEOID_GEOG G WITH(INDEX([geog_sidx]))on G.geom.STIntersects(P.GeoLocation) =1
    	where P.GEOID is null

Open in new window

This may have 1,000 to 100Mil records to match up.
Either way, the query stops and I receive this error:

    Msg 10316, Level 16, State 1, Line 3
    The app domain with specified version id (4) was unloaded due to memory pressure and could not be found.
    The statement has been terminated.

Open in new window

I'm told it's a CLR error, and it has something to do with the spatial index but no explanation on how to troubleshoot it.

Any wisdom would be greatly appreciated.
Question by:Evan Cutler
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 34

Expert Comment

ID: 41790853
1) How much memory has your server (hardware) and what are your SQL Server min memory and max memory settings?

2) What SQL Server version and bitness do you use?

Author Comment

by:Evan Cutler
ID: 41791247
My server has 64 Gb of ram.
It is server 2012 64-bit.

Thank you.
LVL 51

Expert Comment

by:Vitor Montalvão
ID: 41791260
My server has 64 Gb of ram.
How much is configured for SQL Server?
Stressed Out?

Watch some penguins on the livecam!


Author Comment

by:Evan Cutler
ID: 41791330
64Gb is set on SQL Server.
LVL 14

Assisted Solution

by:Nakul Vachhrajani
Nakul Vachhrajani earned 200 total points
ID: 41791358
That may be one of the problem. Per best practices recommended by Microsoft, if RAM > 8GB is available on the server, a minimum of 4GB must be kept reserved for the OS. So, in this case SQL Server max memory should be 60GB (at a maximum, assuming there are no other applications or services running on the server).
LVL 51

Accepted Solution

Vitor Montalvão earned 300 total points
ID: 41791360
So you're not leaving nothing for the operating system.
My recommendation is that you leave a minimum of 4GB to Windows (set MSSQL max memory to 60GB). If you can double it then even better.

Author Comment

by:Evan Cutler
ID: 41791367
ok.  trying.  please be patient.  I'm running this query on 80+ Million records.  The error doesn't appear until somewhere around 40-60M with a 1.1M / hr speed.  I'll do ask you ask, and let you know.

Thank you.
LVL 51

Expert Comment

by:Vitor Montalvão
ID: 41793849
Evan, weekend passed. What is the point of situation today?

Author Closing Comment

by:Evan Cutler
ID: 41816782
The solution worked.

I appreciate your advice.
This was exactly the problem I had.
Thanks much.

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question