减少sqlsever内存 [英] reduce sqlsever memory

查看:116
本文介绍了减少sqlsever内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我在C#中创建了项目,以将数据保存在sql服务器数据库"* .mdf"中
我要在大约10000个文本文件中保存文本的数据
所以我的项目读取了每个文本文件并将文本保存在数据库中
但是我注意到,当我运行项目时,"sqlserver.exe"使用的内存增加了,从而使保存数据非常缓慢,计算机也变得很

我使用此代码将数据保存在"* .mdf"文件中:

hi every one

i made project in c# to save data in sql server data base "*.mdf"
the data i want to save text in about 10000 text files
so my project read each text file and save text in database
but i notice that when i run my project the memory which "sqlserver.exe" used increased to make save data very slow and the computer too

i used this code to save data in "*.mdf" file :

<pre lang="cs">public void NoReturnedValue(string commandstring)
        {
            //insert ,update,delete
            //open connection
            if (this.openconnection() == true)
            {
                //create command and assign the query and connection from the constructor
                SqlCommand cmd = new SqlCommand(commandstring, connection);
                //Execute command
                cmd.ExecuteNonQuery();
                //close connection
                this.closeconnection();
            }
        }




所以我怎样才能减少到sqlsrver.exe占用的内存大小呢? 我希望我清楚地说明了我的问题
感谢all




so how can i reduce to memory size which sqlsrver.exe taken???
i hope that i explaned my problem clearly
thanks all

推荐答案

打开SQL管理工作室并连接到您的SQL实例.在对象资源管理器下,右键单击服务器名称并选择属性-显示服务器属性"对话框

您可以在此处配置内存,例如SQL Server允许的最小和最大内存值

我认为默认值为最小值(0)和最大值(2147483647).这意味着SQL Server将在需要时动态分配自身的内存.

http://technet.microsoft.com/en-us/library/ms181453.aspx [ ^ ]

使用此页面可以查看或修改服务器内存选项.当最小服务器内存"设置为0且最大服务器内存"设置为2147483647时,SQL Server可以在任何给定时间利用最佳内存量,具体取决于多少操作系统和其他应用程序当前正在使用的内存.随着计算机和SQL Server上的负载变化,分配的内存也随之变化.您可以进一步将此动态内存分配限制为以下指定的最小值和最大值."

需要注意的是,即使SQL Server已经分配了自己的内存,但是如果其他应用程序需要,它将按需"将其释放到OS.

如果计算机上没有安装太多内存(例如您正在运行SQL Sever,Visual Studio等),则只需在服务器内存配置中设置一个最大值.但是,这将限制SQL Server的性能.


简而言之,不用担心SQL Server,它非常擅长管理内存-担心您自己的代码!
Open SQL management studio and connect to your SQL instance. Under object explorer, right click on the server name and choose properties - the ''Server Properties'' dialog is shown

You can configure memory here, such as the minimum and maximum memory values allowed by SQL server

I think the defaults are min (0) and max (2147483647). This means SQL server will dynamically allocate itself memory when it is required.

http://technet.microsoft.com/en-us/library/ms181453.aspx[^]

"Use this page to view or modify your server memory options. When Minimum server memory is set to 0 and Maximum server memory is set to 2147483647, SQL Server can take advantage of the optimum amount of memory at any given time, subject to how much memory the operating system and other applications are currently using. As the load on the computer and SQL Server changes, so does the memory allocated. You can further limit this dynamic memory allocation to the minimum and maximum values specified below."

The thing to note is, even though SQL Server has allocated itself memory, it will release it to the OS ''on demand'' if other applications require it.

If you don''t have very much memory installed on the computer (say you are running SQL Sever, Visual Studio etc) then simply set a maximum value in the server memory config. This will limit the performance of SQL Server though.


In short, don''t worry about SQL Server, it''s pretty good at managing memory - worry about your own code!


这篇关于减少sqlsever内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆