{"id":298,"date":"2010-08-09T23:03:37","date_gmt":"2010-08-10T02:03:37","guid":{"rendered":"http:\/\/fabriciodba.wordpress.com\/2010\/08\/09\/utilizacao-de-mais-de-3gb-de-memoria-no-sql-server-em-um-ambiente-32-bits"},"modified":"2017-02-04T14:31:09","modified_gmt":"2017-02-04T16:31:09","slug":"utilizacao-de-mais-de-3gb-de-memoria-no-sql-server-em-um-ambiente-32-bits","status":"publish","type":"post","link":"https:\/\/fabriciolima.net\/blog\/2010\/08\/09\/utilizacao-de-mais-de-3gb-de-memoria-no-sql-server-em-um-ambiente-32-bits\/","title":{"rendered":"Utiliza\u00e7\u00e3o de mais de 3GB de mem\u00f3ria no SQL Server em um ambiente 32 bits"},"content":{"rendered":"<div id=\"msgcns!874FDFFD5EC76B2E!487\" class=\"bvMsg\">\n<p>A algum tempo precisei instalar o Sql Server 2005 Standard Edition 32 bits em um servidor com Windows 2003 Server Enterprise Edtion 32 bits que possuia mais de 4GB de mem\u00f3ria. Gostaria de compartilhar essa experi\u00eancia com voc\u00eas para que possa ajudar a outros que ainda possuem essa necessidade de instala\u00e7\u00e3o do SQL Server em um ambiente 32 bits.Quando se fala em utilizar mais de 4Gb de mem\u00f3ria no SQL Server em um ambiente 32 bits j\u00e1 lembramos das op\u00e7\u00f5es AWE, \/3GB e \/PAE.Encontrei um White Paper da Microsoft que tirou algumas d\u00favidas sobre as op\u00e7\u00f5es AWE e \/3GB. Esse White Paper pode ser baixado no Link: <a href=\"http:\/\/www.microsoft.com\/sqlserver\/2005\/en\/us\/64-bit.aspx\">Advantages of a 64-bit Environment<\/a>.Ap\u00f3s a leitura do white paper, decidi habilitar o AWE dentro do SQL para disponibilizar mais m\u00e9m\u00f3ria para Data Caching.Tamb\u00e9m habilitei a op\u00e7\u00e3o \/3GB no boot.ini do servidor para aumentar o VAS(Virtual Address Space) de 2Gb para 3GB, disponibilizando assim, mais mem\u00f3ria para as opera\u00e7\u00f5es de <em>caching query plans<\/em>, <em>sorting<\/em>,<em> indexing<\/em>,<em> joins<\/em> e conex\u00f5es de usu\u00e1rios.Para habilitar a op\u00e7\u00e3o <strong>AWE<\/strong> no SQL Server, deve-se seguir os seguintes passos:1) Start-&gt;Run-&gt;gpedit.msc2) Abre-se a janela do Group Police Object Editor3) No menu esquerdo, abra Computer Configuration-&gt;Windows Settings-&gt;Secyrity Settings-&gt;Local Policies4) Selecione User Rights Assignment folder, as policies ser\u00e3o mostradas no lado direito.5) Duplo clique em Lock Pages in Memory-&gt; Add User or Group-&gt;Adicione o usu\u00e1rio utilizado para subir o servi\u00e7o <em>do<\/em> MSSQLServer.6) Reiniciar o servi\u00e7o do MSSQLServer.Caso esse procedimento n\u00e3o seja realizado, quando se altera a op\u00e7\u00e3o AWE recebemos o seguinte erro:<a rel=\"WLPP\" href=\"https:\/\/t2y7dq.bay.livefilestore.com\/y1mzwM0EOhw-W1gOrbX9lWRAGR55Ky0qLMzn_c7ohW7TLpwyg-5SPXCC5GVFh5NjR1svvpE5c8t4enjFxGKDBaGad1nrTErLbu-d_9kQhS72YIZhDAi3k53fBo9hi3GFeV0LarlzFE2xlig8LJQe901Cg\/image[16].png?download&amp;psid=1\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0;\" title=\"image\" src=\"https:\/\/t2y7dq.bay.livefilestore.com\/y1m7MC97uY6IJMYp-qmO7flF6OqysuOEZCojHYOpdkG54IozQ97qFc6rDaT027fNdpe7VoW1b_jlCLj8SlVYV-FDvGLj-zwoe-t2HT2C7MfhW1RUiUMwmxtURbi7D2JI_uRl9Rhkid2gjP530xmqRJw4A\/image_thumb[8].png?download&amp;psid=1\" border=\"0\" alt=\"image\" width=\"541\" height=\"167\" \/><\/a> Agora podemos habilitar a op\u00e7\u00e3o AWE, seguem abaixo duas formas de executar esse procedimento:Op\u00e7\u00e3o 1 &#8211; Abrir o Management Studio, clicar com o Bot\u00e3o direito no servidor-&gt;Properties-&gt;Memory-&gt; Habilitar a op\u00e7\u00e3o Use AWE to allocate memory. Pode-se observar que disponibilizei um limite m\u00e1ximo de aproximadamente 5 GB de mem\u00f3ria para o SQL Server.<a rel=\"WLPP\" href=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2010\/10\/awe5b55d.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0;\" title=\"AWE\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2010\/10\/awe5b55d.jpg?w=300\" border=\"0\" alt=\"AWE\" width=\"474\" height=\"264\" \/><\/a><\/p>\n<p>Op\u00e7\u00e3o 2 &#8211; Executar o script abaixo:<\/p>\n<div style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New',courier,monospace; direction: ltr; font-size: 8pt; overflow: auto; cursor: text; border: 1px solid silver; padding: 4px;\">\n<div style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">sp_configure <span style=\"color: #006080;\">'show advanced options'<\/span>,1<\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">go<\/span><\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">reconfigure<\/span><\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">go<\/span><\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">sp_configure <span style=\"color: #006080;\">'awe enabled'<\/span>,1<\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">go<\/span><\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">reconfigure<\/span><\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">go<\/span><\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">sp_configure <span style=\"color: #006080;\">'show advanced options'<\/span>,0<\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">go<\/span><\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">reconfigure<\/span><\/pre>\n<\/div>\n<\/div>\n<p>Em seguida, deve-se reiniciar o servi\u00e7o do SQL Server para que as altera\u00e7\u00f5es passem a valer.<\/p>\n<p>Executando a query abaixo, pode-se ver o quanto que o SQL Server reconheceu de mem\u00f3ria e o quanto de mem\u00f3ria que est\u00e1 sendo utilizada.<\/p>\n<div style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New',courier,monospace; direction: ltr; font-size: 8pt; overflow: auto; cursor: text; border: 1px solid silver; padding: 4px;\">\n<div style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\">\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">select<\/span> counter_name ,cntr_value,<span style=\"color: #0000ff;\">cast<\/span>((cntr_value\/1024.0)\/1024.0 <span style=\"color: #0000ff;\">as<\/span> <span style=\"color: #0000ff;\">numeric<\/span>(8,2)) <span style=\"color: #0000ff;\">as<\/span> Gb<\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">from<\/span> sys.dm_os_performance_counters<\/pre>\n<pre style=\"text-align: left; line-height: 12pt; background-color: white; margin: 0px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;\"><span style=\"color: #0000ff;\">where<\/span> counter_name <span style=\"color: #0000ff;\">like<\/span> <span style=\"color: #006080;\">'%server_memory%'<\/span>;<\/pre>\n<\/div>\n<\/div>\n<p>Segue o resultado.<\/p>\n<p><a rel=\"WLPP\" href=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2010\/10\/image5b205d.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0;\" title=\"image\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2010\/10\/image5b205d.png?w=300\" border=\"0\" alt=\"image\" width=\"559\" height=\"138\" \/><\/a><\/p>\n<p>At\u00e9 esse momento, tinha verificado que o SQL Server reconheceu quase 5 GB de mem\u00f3ria, entretanto ainda n\u00e3o tinha visto ele utilizando toda essa mem\u00f3ria. Para isso, fiz uma query que ficava em loop fazendo um select em uma vari\u00e1vel do tipo <em>table<\/em> e inserindo nela mesma. Acompanhando a query, a utiliza\u00e7\u00e3o da mem\u00f3ria aumentou rapidamente conforme pode ser visualizada na figura abaixo.<\/p>\n<p><a rel=\"WLPP\" href=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2010\/10\/image5b195d.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0;\" title=\"image\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2010\/10\/image5b195d.png?w=300\" border=\"0\" alt=\"image\" width=\"561\" height=\"139\" \/><\/a><\/p>\n<p>Quando o SQL Server utilizou o m\u00e1ximo de mem\u00f3ria que eu havia disponibilizado eu parei a execu\u00e7\u00e3o da query. A figura abaixo demonstra toda a utiliza\u00e7\u00e3o da mem\u00f3ria.<\/p>\n<p><a rel=\"WLPP\" href=\"http:\/\/fabriciodba.files.wordpress.com\/2010\/08\/clip_image0015b65d.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0;\" title=\"clip_image001\" src=\"http:\/\/fabriciodba.files.wordpress.com\/2010\/08\/clip_image0015b65d.jpg?w=300\" border=\"0\" alt=\"clip_image001\" width=\"563\" height=\"142\" \/><\/a><\/p>\n<p>Entretanto, visualizando a utiliza\u00e7\u00e3o de mem\u00f3ria por processo pelo <em>task manager<\/em>, o servi\u00e7o do SQL s\u00f3 estava utilizando 100 MB de mem\u00f3ria. Quando voc\u00ea utiliza a op\u00e7\u00e3o <em>AWE<\/em> no SQL Server o consumo de mem\u00f3ria do processo do SQL Server n\u00e3o pode ser mais acompanhado pelo <em>task manager<\/em> pois o mesmo n\u00e3o \u00e9 o real.<\/p>\n<p>Para habilitar a op\u00e7\u00e3o <strong>\/3GB<\/strong>, basta seguir os seguintes passos:<\/p>\n<p>1 \u2013 Bot\u00e3o direito em Meu Computador -&gt; Advanced -&gt; Startup and Recovery-&gt; Setting-&gt;Edit<\/p>\n<p>2 \u2013 Adicionar \/3GB no fim do Texto que se abre, como por exemplo:<\/p>\n[boot loader]\n<p>timeout=30<\/p>\n<p>default=multi(0)disk(0)rdisk(0)partition(1)\\WINDOWS<\/p>\n[operating systems]\n<p>multi(0)disk(0)rdisk(0)partition(1)\\WINDOWS=&#8221;Windows Server 2003, Standard&#8221; \/noexecute=optout \/fastdetect <strong>\/3GB<\/strong><\/p>\n<p>J\u00e1 a op\u00e7\u00e3o <strong>\/PAE<\/strong>, com ajuda do pessoal do f\u00f3rum TechNet, descobri que quando o Windows Server 2003 R2 identifica que o servidor possui mais de 4GB de mem\u00f3ria, ele j\u00e1 habilita a op\u00e7\u00e3o \/PAE automaticamente fazendo com que o windows mesmo sendo 32 bits j\u00e1 utilizasse meus 8GB de mem\u00f3ria. Logo, n\u00e3o precisei habilit\u00e1-la.<\/p>\n<p>Sempre que voc\u00ea tiver dispon\u00edvel hardwares e softwares 64 bits, \u00e9 aconselh\u00e1vel que voc\u00ea instale o sistema operacional e o SQL Server em 64 bits para obter o m\u00e1ximo de desempenho poss\u00edvel que seu hardware disponibiliza. Entretanto, ainda existem alguns casos onde temos limita\u00e7\u00f5es e ainda temos que instalar o SQL Server na vers\u00e3o 32 bits. Espero que possa ter ajudado algu\u00e9m que ainda tenha essa necessidade. Fiquem a vontade para concordar, discordar e acrescentar informa\u00e7\u00f5es sobre o assunto desse post nos coment\u00e1rios.<\/p>\n<p>&nbsp;<\/p>\n<p><b>Gostou desse Post?<\/b><\/p>\n<p>Curta, comente, compartilhe\u2026<\/p>\n<p>Assine meu canal no <a href=\"https:\/\/www.youtube.com\/channel\/UCeBRAO_LLrUdSrOXIywjzRA\" target=\"_blank\">Youtube<\/a> e curta minha p\u00e1gina no <a class=\"external-link wpel-icon-left\" href=\"https:\/\/www.facebook.com\/FabricioLimaSolucoesemBancodeDados\/\" target=\"_blank\" rel=\"nofollow external noopener noreferrer\" data-wpel-link=\"external\">Facebook<\/a> para receber Dicas de Leituras, V\u00eddeos e Eventos sobre SQL Server.<\/p>\n<p>At\u00e9 a pr\u00f3xima.<\/p>\n<p>Fabr\u00edcio Lima<\/p>\n<p>MCITP \u2013 Database Administrator<\/p>\n<p>Consultor e Instrutor SQL Server<\/p>\n<p>Trabalha com SQL Server desde 2006\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>A algum tempo precisei instalar o Sql Server 2005 Standard Edition 32 bits em um servidor com Windows 2003 Server Enterprise Edtion 32 bits que possuia mais de 4GB de mem\u00f3ria. Gostaria de compartilhar essa experi\u00eancia com voc\u00eas para que possa ajudar a outros que ainda possuem essa necessidade de instala\u00e7\u00e3o do SQL Server em [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[3,280],"tags":[75,77,73,82,78,76,23,25,80,29,79,49,33,74,81],"class_list":["post-298","post","type-post","status-publish","format-standard","hentry","category-administracao-de-bd","category-virtual-pass-br","tag-3gb","tag-pae","tag-32-bits","tag-64-bits","tag-advantages-of-a-64-bit-environment","tag-awe","tag-dba","tag-dmv","tag-dm_os_performance_counters","tag-memoria","tag-sp_configure","tag-sql","tag-sql-server","tag-sql-server-32-bits","tag-target-server-memory"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/comments?post=298"}],"version-history":[{"count":0,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/298\/revisions"}],"wp:attachment":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/media?parent=298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/categories?post=298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/tags?post=298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}