Ho una query sql che sto tentando di eseguire su un server con 8 GB di RAM. Se riavvio il server, si avvia e l'utilizzo della memoria è di circa 1,2 GB.Problemi di query SQL e RAM
Se si esegue la query, al termine della query, l'utilizzo della RAM passa a circa 4 GB e sembra rimanere lì, anche durante la notte.
Se si esegue nuovamente la query (il giorno successivo), l'utilizzo della RAM sale a circa 7 GB e rimane lì anche quando la query è terminata.
Se si tenta di eseguire nuovamente la query dopo aver atteso 24 ore, l'utilizzo della RAM è ancora a 7 GB, ma questa volta la query inizia a restituire gli errori di memoria esauriti.
La mia domanda è, come si cancella l'utilizzo della memoria al termine dell'esecuzione della query? Idealmente, sarebbe bene se lo script sql stesso potesse cancellare l'utilizzo della RAM al termine del suo lavoro principale.
La versione del server è:
E 'Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64).
Il messaggio di errore è:
System.Data.SqlClient.SqlException (0x80131904): There is insufficient memory available in the buffer pool.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at Project1.Form1.intenseProcess3() in c:\Users\oshirowanen\Documents\Visual Studio 2013\Projects\Project1\Form1.cs:line 117
ClientConnectionId:33f515db-0086-4f88-a8fd-e7779d92d030
Error Number:802,State:20,Class:17 SqlException caught.
È possibile aggiungere messaggi di errore dettagliati? –
In SQL Server Management Studio, fare clic con il pulsante destro del mouse sull'istanza del server, selezionare Proprietà, fare clic sulla pagina "Memoria" e assicurarsi che "Memoria del server massima" sia impostata su qualcosa di ragionevole, nel proprio caso, 4096.Per impostazione predefinita, SQL Server utilizzerà tutta la memoria disponibile e la manterrà. questo è il primo passo. – pmbAustin
Spero che questo sia solo il tuo server di test personale o qualcosa del genere. Altrimenti ti consiglierei di acquistare più RAM. –