Database consuming lot of Physical memory

Hi ,
My database is on version 11.1.0.7.0 and on SUN SOLARIS SPARC.
My server admin just informed me that my database is using lot of physical memory , which i understand is RAM.
I am looking on google also but i am not able to find a way in which i can check on it and see how it can be controlled.
Any help/suggestion would be highly appreciated.
Regards
Kk

There are 2 basic methods that Oracle uses memory.
Statically. Oracle allocates memory (for the SGA) when it starts. This memory remains fixed in size.
Dynamically. In order to service a client, memory is needed for that client session. Oracle dynamically allocates memory for such sessions (called the PGA).
When Oracle memory consumptions grows, it must be dynamically allocated memory. Static memory is just that - static. It does not grow in size.
The usual reason for PGA memory consumption to grow is incorrectly designed and coded bulk processing. A single Oracle server process can easily consume all available free memory on the server as Oracle dynamically increases the size of the PGA of the process running the flawed PL/SQL code.
However, one should not be looking at o/s command line commands to determine Oracle processes's memory utilisation. The output of such commands are often incorrectly interpreted.. as shared memory can be (and often is) included to provide a process's memory utilisation. There are notes on Metalink (mysupport.oracle.com) on the topic and how to correctly use CLI commands to view Oracle process memory utilisation.
An easier, and more accurate, view of Oracle memory utilisation can be obtained from Oracle's virtual performance views.
So, a sysadmin e-mailing a ps (Unix/Linux process listing) showing a particular Oracle process "+using too much memory+" is not really solid enough evidence that memory is being abused. One needs to look closer at the type of memory used by the process.

Similar Messages

  • Plugin consuming the entire physical memory avilable

    Hello,
    I wrote a plugin using acrobat SDK to convert my pdf files to image format. When i run this plugin in a batch mode on multiple files - which are multipage files - Acrobat eats up the entire physical memory after processing certain files. I have ensured that whatever objects i acquired or allocated are freed up in the code. Still after running memory detection tools i am not able to figure out how come acrobat - or plugin - is eating up the memory available. Can someone suggest a solution to the same. Is there any way we can avoid this. If i am missing something please let me know.
    Thanks in advance.
    Regards
    hary

    >
    > reachhary
    > Aug 12, 2010
    > Dec 30, 2010 7:16 AM
    >
    > Plugin consuming the entire physical memory avilable
    >
    > Hello,
    > I wrote a plugin using acrobat SDK to convert my pdf files to image
    > format. When i run this plugin in a batch mode on multiple files -
    > which are multipage files - Acrobat eats up the entire physical memory
    > after processing certain files. I have ensured that whatever objects i
    > acquired or allocated are freed up in the code. Still after running
    > memory detection tools i am not able to figure out how come acrobat -
    > or plugin - is eating up the memory available. Can someone suggest a
    > solution to the same. Is there any way we can avoid this. If i am
    > missing something please let me know.
    > Thanks in advance.
    > Regards
    > hary
    >
    > lrosenth
    > Apr 6, 2009
    > 1. Dec 30, 2010 8:45 AM in response to: reachhary
    > Re: Plugin consuming the entire physical memory avilable
    >
    > No clue how your software works - so really can't debug it for you...
    >
    > Make sure you release each page after you image it - that's a common
    > mistake.  Otherwise, watch your memory, etc.
    >
    > You also don't mention what version of Acrobat you are using...I
    > assume you are current?!?

    We could all benefit if you post your code and take a look at it. 
    Francis Fukuyama

  • Oracle.exe consuming 10GB of total 16GB physical memory.

    I am using Oracle 11g on windows 2008 R2 during utilization check of memory i found the my ORACLE.EXE is consuming 10GB of physical memory. my total physical memory size is 16GB. I am not getting why my oracle.exe is consuming so much of memory.
    My SGA details are as follows :
    SQL> show sga
    Total System Global Area 1.0689E+10 bytes
    Fixed Size 2185160 bytes
    Variable Size 2046822456 bytes
    Database Buffers 8623489024 bytes
    Redo Buffers 16977920 bytes
    Please suggest how can i reduce my memory utilization??

    Hii, thanks for the useful documents.
    I have checked the parameter n the output is as follows
    SQL> show parameter target
    NAME TYPE VALUE
    archive_lag_target integer 0
    db_flashback_retention_target integer 1440
    fast_start_io_target integer 0
    fast_start_mttr_target integer 0
    memory_max_target big integer 0
    memory_target big integer 0
    parallel_servers_target integer 128
    pga_aggregate_target big integer 2G
    sga_target big integer 10G
    SQL> select component,current_size,min_size,max_size,user_specified_size,granule_size from v$memory_dynamic_components;
    COMPONENT CURRENT_SIZE MIN_SIZE MAX_SIZE USER_SPECIFIED_SIZE GRANULE_SIZE
    shared pool 1879048192 1879048192 1879048192 0 33554432
    large pool 33554432 33554432 33554432 0 33554432
    java pool 134217728 134217728 134217728 0 33554432
    streams pool 0 0 0 0 33554432
    SGA Target 1.0737E+10 1.0737E+10 1.0737E+10 1.0737E+10 33554432
    DEFAULT
    buffercache 8623489024 8623489024 8623489024 0 33554432
    KEEP
    buffercache 0 0 0 0 33554432
    RECYCLE
    buffer cache 0 0 0 0 33554432
    DEFAULT 2K
    buffercache 0 0 0 0 33554432
    DEFAULT 4K
    buffercache 0 0 0 0 33554432
    DEFAULT 8K
    buffercache 0 0 0 0 33554432
    DEFAULT 16K
    buffercache 0 0 0 0 33554432
    DEFAULT 32K
    buffercache 0 0 0 0 33554432
    Shared IO
    Pool 0 0 0 0 33554432
    PGA Target 2147483648 2147483648 2147483648 2147483648 33554432
    ASM
    BufferCache 0 0 0 0 33554432
    Please tell me by changing or setting which parameter i can reduce my physical memory size???

  • Component controller is consuming lots of memory

    Hi All,
    I have an WebDynpro application and a component controller (MyCompController) too where I have written most of the business specific code. The basis team informed that the component controller (MyCompController) is consuming lots of memory.
    Could anybody suggest me how to takle this problem. I dont have any other details and I am new to handle this kind of activity.
    Thanks & Regards,
    Patana

    Hi Patana
    Your controller can consume lots of memory because of lots of unnecessary data is loaded in advance and do not used actually. Try to analyze the following points:
    1. Unnecessary data is loaded into the context nodes in advance. Do not load all the data into the context in wdInit() method (do not fill in all the models too). This is not the right way. Instead try to use supply-functions for each context node with data. Supply-function will be called by Webdynpro automatically only when the data is actually required to be shown on UI.
    2. Unnecessary embedded Webdynpro components are created and loaded in memory in advance. Do not create embedded Webdynpro components manually in wdInit() method. Instead try to setup component usages with Create Mode option = OnDemand. Then Webdynpro will create the components automatically when this is really required.
    BR, Sergei

  • Flash builder 4.7 consuming lot of memory in VMware VDI environment.

    Flash builder 4.7 consuming lot of memory in VMware VDI environment. When we debugg the application then it is throwing out of memory exception. We need to close and relaunch Flash builder IDE numerous times. Can you please help us with setting changes we need to make for flash builder or VMware VDI environment so that we can resolve this issue?

    Hi Atul_Saini,
    So I checked your link and all seems correct on my computer.
    At the bottom of the link you provided there is "see also" section, about activation / deactivation.
    I did not deactivated my licenses before my window re-install, and if now I go to Flash Builder -> Help , desactivation button is greyed out. Could it be the source of my problem that I used my licenses on two computer and did not deactivated them ?
    If yes, how could I deactivate thoses products ? I searched on my profile but I can't find a way to do it.

  • Mkmapview on zoom in or zoom out consumes lot of memory

    Hello,
    In my application i am using mkmapview as the main view and showing images (around 75 images) on the map by annotation.
    on zoom in or zoom out mapview consumes lot of memory and after some time it recives memory warning then application gets crash.
    any suggestion for that.
    Thank u in advance.

    Place the property node inside a case structure and enable it when the iteration terminal is "1". (not zero!)
    And please place a small wait inside your loop, there is no reason it should spin that fast. (Since the data never changes in your example, the entire graph terminal and inner loops belong outside the main while loop. However, I assume that your real application is different )
    NOTE: you could also use the "first run?" primitive or enable it when [i]=0, but in this case you would need a small sequence structure to ensure it happens after ther graph terminal is written for the first time.
    Also note that xy graphs take complex data, simplifying the wiring and data structures.
    LabVIEW Champion . Do more with less code and in less time .

  • Operationsmanager database is consuming lot of space

    Hi All,
    I have a issue, My operations manager database is of 40GB and out of which 19 GB was always free.
    From the past 1 - 2 weeks my database is occupying lot of space and currently i have only 9GB free.
    When i ran a SQL query to pull what data  of what is consuming lot of space below is the report.
    SQL Query what i used:
    SELECT so.name, 
    8 * Sum(CASE WHEN si.indid IN (0, 1) THEN si.reserved END) AS data_kb, 
    Coalesce(8 * Sum(CASE WHEN si.indid NOT IN (0, 1, 255) THEN si.reserved END), 0) AS index_kb, 
    Coalesce(8 * Sum(CASE WHEN si.indid IN (255) THEN si.reserved END), 0) AS blob_kb 
    FROM dbo.sysobjects AS so JOIN dbo.sysindexes AS si ON (si.id = so.id) 
    WHERE 'U' = so.type GROUP BY so.name  ORDER BY data_kb DESC
    Output:
    Last 5 days back the report (When the space came to 12GB)
    name
    data_kb
    index_kb
    StateChangeEvent
    7347832
    753376
    PerformanceSource
    4001200
    1783192
    PerformanceData_40
    2310000
    671704
    PerformanceData_38
    2240256
    648800
    PerformanceData_42
    2063936
    596704
    AlertHistory
    1412752
    177984
    PerformanceData_36
    1390320
    406616
    Alert
    1369984
    162984
    PerformanceData_44
    764976
    224600
    RecursiveMembership
    482152
    176856
    Event_40
    420400
    5912
    Event_42
    313984
    4320
    Event_36
    290688
    4000
    Event_38
    289600
    3808
    Event_34
    252976
    3352
    In last 3 days the new report (Currently when the space came to 9GB)
    name
    data_kb
    index_kb
    blob_kb
    StateChangeEvent
    7417272
    764896
    0
    PerformanceSource
    4009712
    1786904
    0
    PerformanceData_46
    3626432
    1042144
    0
    PerformanceData_40
    2310000
    671704
    0
    PerformanceData_38
    2240256
    648800
    0
    PerformanceData_42
    2063936
    596704
    0
    PerformanceData_44
    1873840
    548888
    0
    AlertHistory
    1468880
    182208
    0
    Alert
    1399576
    152832
    0
    Event_46
    526832
    6936
    0
    RecursiveMembership
    482728
    177240
    0
    Event_40
    420400
    5912
    0
    Event_42
    313984
    4320
    0
    Event_44
    306608
    4184
    0
    Event_36
    290688
    4000
    0
    My Current grooming settings for Operationsmanager DB are as below.
    Can any one help me in how do i reduce this space occupation please ?
    Gautam.75801

    1) You may refer to the following SQL statement to find out the lare table query of operations Manager Database and Operations manager DataWarehouse.
    SELECT TOP 1000
    a2.name AS [tablename], (a1.reserved + ISNULL(a4.reserved,0))* 8 AS reserved,
    a1.rows as row_count, a1.data * 8 AS data,
    (CASE WHEN (a1.used + ISNULL(a4.used,0)) > a1.data THEN (a1.used + ISNULL(a4.used,0)) - a1.data ELSE 0 END) * 8 AS index_size,
    (CASE WHEN (a1.reserved + ISNULL(a4.reserved,0)) > a1.used THEN (a1.reserved + ISNULL(a4.reserved,0)) - a1.used ELSE 0 END) * 8 AS unused,
    (row_number() over(order by (a1.reserved + ISNULL(a4.reserved,0)) desc))%2 as l1,
    a3.name AS [schemaname]
    FROM (SELECT ps.object_id, SUM (CASE WHEN (ps.index_id < 2) THEN row_count ELSE 0 END) AS [rows],
    SUM (ps.reserved_page_count) AS reserved,
    SUM (CASE WHEN (ps.index_id < 2) THEN (ps.in_row_data_page_count + ps.lob_used_page_count + ps.row_overflow_used_page_count)
    ELSE (ps.lob_used_page_count + ps.row_overflow_used_page_count) END ) AS data,
    SUM (ps.used_page_count) AS used
    FROM sys.dm_db_partition_stats ps
    GROUP BY ps.object_id) AS a1
    LEFT OUTER JOIN (SELECT it.parent_id,
    SUM(ps.reserved_page_count) AS reserved,
    SUM(ps.used_page_count) AS used
    FROM sys.dm_db_partition_stats ps
    INNER JOIN sys.internal_tables it ON (it.object_id = ps.object_id)
    WHERE it.internal_type IN (202,204)
    GROUP BY it.parent_id) AS a4 ON (a4.parent_id = a1.object_id)
    INNER JOIN sys.all_objects a2  ON ( a1.object_id = a2.object_id )
    INNER JOIN sys.schemas a3 ON (a2.schema_id = a3.schema_id)
    WHERE a2.type <> N'S' and a2.type <> N'IT'  
    2) Moreover, your query return that the suddndly increase of DB siza came from performance data and you may use the following queryto find out which rule generated a hugh mount of performance data.
    select r.rulename, count(*) from performancedataallview pv
    inner join performancesource ps on pv.performancesourceinternalid=ps.performancesourceinternalid
    inner join rules r on r.ruleid=ps.ruleid
    group by r.rulename
    order by count(*) desc
    http://blogs.technet.com/b/kevinholman/archive/2007/10/18/useful-operations-manager-2007-sql-queries.aspx
    Roger

  • Kernel_task consumes a lot of real memory

    (I do not speak english, all translated by google. Sorry.)
    The process "kernel_task" of my MacBook Air is always occupying a lot of "Real Memory", always up to 1.5GB. Why? How can I solve?
    Thanks and sorry bad english.

    Read this document.
    http://reviews.cnet.com/8301-13727_7-20091848-263/kernel-task-taking-up-ram-in-o s-x/

  • Relative size of sga_max_size and sga_target to the physical memory

    Dear Experts,
    I have installed oracle 10.2.0.4 on AIX 5.3 with 32 GB of physical memory.
    Let us say other applications on the server consume 10 GB of physical memory.
    Now how should i plan the size of SGA_TARGET and SGA_MAX_SIZE on the same.

    As per Oracle® Database Performance Tuning Guide 10g Release 2 (10.2):
    You must then divide the resulting memory between the SGA and the PGA.
    For OLTP systems, the PGA memory typically accounts for a small fraction of the total memory available (for example, 20%), leaving 80% for the SGA.
    For DSS systems running large, memory-intensive queries, PGA memory can typically use up to 70% of that total (up to 2.2 GB in this example).
    Good initial values for the parameter PGA_AGGREGATE_TARGET might be:
    For OLTP: PGA_AGGREGATE_TARGET = (total_mem * 80%) * 20%
    For DSS: PGA_AGGREGATE_TARGET = (total_mem * 80%) * 50%
    where total_mem is the total amount of physical memory available on the system.
    (http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14211/memory.htm#i49320)

  • Physical memory cache behavior in Windows Server 2008 Enterprise

    I have a question regarding how windows manages the cache portion of phyiscal memory.  I have 2 servers which are identical OS configurations, hardware and experience nearly identical workloads.  Server 1 appears to use its cache a lot. I often
    see physical cache at at 75% of total memory (total is 16gb for both servers). I also see that the cache stays this high
    even when overall memory utilization is minimal (say approx. 3-4gb out of 16gb for long durations). I suppose this means windows memory manager is keeping pages in the cache because it anticipates it may need them again, but would overwrite them with
    new data if new processes needed it (I think of  this cached memory when the system is near idle as "available" but correct me if I am wrong?)
    Server 2 (again same workload and identical hardware, OS, configuration) doesn't appear to use cache as much. In fact, cache is always low round the clock (2 gbs usually) even when there is little to no memory utilization from processes outside the OS. Basically,
    it is low when the server is near idle, while the server 2 keeps it very high during the same period of minimal workload. Why the difference? Does this behavior sound normal?  Please advise. I am not a Windows Admin btw. I have a rudimentary understanding
    of memory.. or so I believe at least : )
    Thanks.

    Hi,
    Although both server are identical OS configurations, hardware and experience nearly identical workloads, there are still differences between them. We can use task manager on both server and Check which processes are using physical memory, please go through
    the below article to check more details about windows performance issue:
    Troubleshooting Windows Performance Issues: Lots of RAM but no Available Memory
    http://blogs.technet.com/b/mspfe/archive/2012/12/06/lots-of-ram-but-no-available-memory.aspx
    Regards,
    Yan Li
    TechNet Subscriber Support
    If you are
    TechNet Subscription
    user and have any feedback on our support quality, please send your feedback
    here.
    Regards, Yan Li

  • How to make use of the spare physical memory under buffered I/O of Essbase

    We encountered an issue of the physical memory allocation of the server running Essbase with buffered I/O mode. We have implemented some cache setting in Essbase but still found that the disk I/O is quite high. Also we observed that Windows 2003 server cannot make use of the spare physical memory available as the system cache for database files of Essbase.
    As allocating more memory as Essbase cache might not help, we would like to know other than changing to direct I/O mode, any other options can improve the disk I/O performance?
    Thanks!

    Sandeep Reddy wrote:
    Hi Hyperion_User,
    1. Disk IO performance,It mighe depend on quite a few things , one of the aspects might be your storage system. It can depend on the disk configuration too ( i.e if your disk is SAN or NAS, then it depends on the configuration like Raid ..etc).
    2. It depends on the HBA ( host bus adapter).
    3. Let me try to explain with diagram.
    http://www.c-sharpcorner.com/uploadfile/freebookarticles/apress/2008dec16010208am/DataStorageDesign/Images/159059214X-1404.1.gif
    4. It might depend on the HBA and even on the switch speed.
    5. Buffered IO is a very generic setting,which most of them use( that should not be an issue).
    6. Even if you have 30 to 40 GB free memory, every application in essbase has a limitation to it maximum usage ( 2 GB on windows ). Refer to DBAG for more information on this .
    Sandeep Reddy Enti
    HCC
    http://hyperionconsultancy.com/
    Thanks for your detailed advice. I just wonder if more physical memory can help to improve the disk I/O being used for concurrent read/write access. We are using Windows 2003 Enterprise Edition and not sure whether some spare physical memory can be used for this purpose.
    Thanks again!

  • Physical Memory: 97%

    I have a SQL Server 2008 R2 on Windows Server 2008 R2, on 64-bit virtual machine, dual processors dual quad core , and 32 GB RAM.
    If I restart the server, and after all the processes and services start running, the used memory is not more than 4 ~ 6 GB (I don't remember exactly, but small compared to the overall 32 GB). Every day the used memory increases for 2~3 GB!, till it reaches
    97% of the physical memory (31 GB),  29 GB of them for the SQL Server:
    My question is how can I know what SQL Server processes or queries causes those increases in the memory? and if it is a process or query, why the used memory is not released after that process or query finishes ?!
    Honestly, there is no complain about the performance of the server, but the weird thing is that as much as I give the server RAM as much as the SQL Server takes! The server was 8 GB and I increased it to 16 then 32 GB, but the SQL Server keeps eating more
    and more!

    Hi,
    >>If I restart the server, and after all the processes and services start running, the used memory is not more than 4 ~ 6 GB (I don't remember exactly, but small compared to the overall 32 GB). Every day the used memory increases for 2~3 GB!,
    till it reaches 97%
    This is the way SQL Server memory works.When you restarted it its usage was low slowly you started running complex queries on SQL server which required pages from disk now SQL server started bringing these pages from disk into memory to make sure your query
    is satisfied .Now when second time you use same query it will be fast as comapared to previous attempt as now there is no use of bringing pages in memory .Now if SQL would have released memory back your time taken would have been same and you would complain
    about query being slow.This is the reaosn SQL caches as much data page it can so as to satify query from meory not picking pages from disk which is costly.But if Os faces presasure and SQLOS asks SQL server to trim its memory consuption it will do it politely.So
    please dont be alarmed with SQL server using memory.
    PLease dont look at task manager for SQL server memory consumption it might not show you correct memory utilization .I always recommend below DMV
    select
    (physical_memory_in_use_kb/1024)Memory_usedby_Sqlserver_MB,
    (locked_page_allocations_kb/1024 )Locked_pages_used_Sqlserver_MB,
    (total_virtual_address_space_kb/1024 )Total_VAS_in_MB,
    process_physical_memory_low,
    process_virtual_memory_low
    from sys. dm_os_process_memory
    If you do not want SQL server to use much memory you can change it from sp_configure by setting lower value for max server memory.But I am in favour you shoudl not do that .Set an optimum value for max server memory leaving 7-8 G for OS and other processes
    running.
    >>My question is how can I know what SQL Server processes or queries causes those increases in the memory?
    I have never tried that and its little difficult to find what process unless that process is runnin.There is DMV sys.dm_os_buffer_descriptor which will tell you which database is using how much memory.Below query will resturn count of page loaded by each
    database
    http://technet.microsoft.com/en-us/library/ms173442.aspx
    SELECT COUNT(*)AS cached_pages_count
    ,CASE database_id
    WHEN 32767 THEN 'ResourceDb'
    ELSE db_name(database_id)
    END AS database_name
    FROM sys.dm_os_buffer_descriptors
    GROUP BY db_name(database_id) ,database_id
    ORDER BY cached_pages_count DESC;
    For further reading about memory to know that its really a normal behavior please see
    Basics of memory
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Solaris 10 physical memory vs swap

    We are running Solaris 10 Sparc 64 bit. We have total 8G RAM. It seems like all the processes are swapping even though there is free physical memory. Project for oracle user is 6gb.
    prstat -t for oracle user is swap=2250 rss=2450. Why am I swapping?? I would expect to use up all physical memory before swapping.
    thanks

    What Solaris reports as "free memory" isn't unused memory, it is the "free list" which is a pool of memory pages which the system has decided can be reused to meet future memory demands. If the size of this pool falls below a certain limit, based on the memory size, the system will do a scan to add additional pages to the list. The pages aren't necessarily empty, they are just considered available for reuse. As a result, the free list doesn't go to zero even if you're swapping. The system is constantly adding new pages to the free list which then get consumed by an excessive memory demand.

  • RAC node process using 25% physical memory

    We have a QA server is non-RAC, and production is two-node RAC. We have a migration app that does an INSERT from SELECT over 2 instances. All of the machines have been in successful day-to-day use for several months...our only troublespot seems to be the migration app.
    Today we started the app on the QA server and watched the oracle processes using top. They ran normally and finished without any problems.
    The same app started on either of the RAC nodes produced process memory errors and died.
    As the app ran, there was a process reading the data from the source instance and a process writing to the target instance. We confirmed this by querying the session data. It doesn't matter which of the nodes runs which target process...the result is the same.
    The reading process(session) on the source instance seems to run normally. The write process on the target instance, however, begins slowly accumulating memory in about 16M chunks and holds on to them.
    We saw this in the RES and in the MEM columns of top. The target process never released any memory, but slowly grabbed it until its
    RES was 4GB and the %MEM was about 30%. The app then died with process memory error. This is reproducible over several runs.
    ( Per Metalink Note 567506.1, the recommended value for Linux 64-bit is 4294967295 ..we have that set. )
    There are other oracle processes and instances running on both nodes which do not seem to be affected. The total number of processes on each machine is around 750..much lower than the nprocs ulimit of 63K.
    These process are both oracle sessions spawned by the app.
    I haven't seen any info on the web or Metalink that matches these symptoms, so I thought I'd try the experts.
    Why would the write session continuously use up physical memory, but only on RAC nodes?
    We are running RHEL5 on Dell Poweredge 2950 w 16K Physical mem. Version of 10g is R2.0.4.

    user12017889 wrote:
    The write process on the target instance, however, begins slowly accumulating memory in about 16M chunks and holds on to them.Exactly what process is this? An Oracle server process? Dedicated or shared server?
    We saw this in the RES and in the MEM columns of top. The target process never released any memory, but slowly grabbed it until its
    RES was 4GB and the %MEM was about 30%. How does the writer process work? Does it use PL/SQL? Does it use bulk processing? How does it call the reader process? Or does the reader process call it? Is this over a database link.
    The app then died with process memory error. This is reproducible over several runs.If this is an Oracle server process, then there should be an entry in the alert log of the instance that recorded the crash and includes the name of the trace file generated by the crash.

  • Gathering physical memory for SQL 2005..SQL 2014

    Hi All,
    I'm trying to write a query to gather physical memory across my SQL servers (from SQL 2005 to SQL 2012).
    However, the sys.dm_os_sys_info DMV (the column for physical memory) is not the same after the switch to SQL 2012+.
    Here is the original query:
    SELECT
    @@SERVERNAME AS ServerName,
    CASE WHEN LEFT(CAST(serverproperty('productversion') as char), 1) = 9 THEN '2005'
    WHEN LEFT(CAST(serverproperty('productversion') as char), 4) = 10.0 THEN '2008'
    WHEN LEFT(CAST(serverproperty('productversion') as char), 4) = 10.5 THEN '2008R2'
    WHEN LEFT(CAST(serverproperty('productversion') as char), 2) = 11 THEN '2012'
    END AS MajorVersion,
    SERVERPROPERTY ('productlevel') AS MinorVersion,
    SERVERPROPERTY('productversion') AS FullVersion,
    SERVERPROPERTY ('edition') AS Edition,
    SERVERPROPERTY('collation') as Collation,
    cpu_count as CpuCount,
    physical_memory_in_bytes/1024/1024 as PhysMemMB
    FROM [sys].[dm_os_sys_info]
    If I run that on SQL 2014, it fails because 'physical_memory_in_bytes' is now called 'physical_memory_kb'
    I tried to do an IF..THEN..ELSE:
    IF (cast(serverproperty('productversion') as char) like '11.%')
    Then change the query accordingly but it would fail because i guess when it tried to parse the whole code, one of the T-SQL variations would have a column that did not exist in that particular version of SQL Server.
    Is there a way I can get physical memory across SQL 2005..SQL 2012 or rewrite the T-SQL above to be able to run on both?
    Thanks in advance

    Oh it seemed like you are asking SQL Server memory. the name for physical memory column ha changed only in SQL Server 2012. I wrote below script  just first run select SERVERPROPERTY('ResourceVersion')  to get exact resource database version of
    SQL Server 2012 and then replace it in below script
    IF cast ( SERVERPROPERTY('ResourceVersion') as char (10) )= '11.00.2000'--2012 resource database version
    select (physical_memory_kb/1024)as Physical_mem_MB from sys.dm_os_sys_info
    else
    select (physical_memory_in_bytes/1024/1024) as physical_mem_MB from sys.dm_os_sys_info
    Edit: A more optimized query
    If cast (LEFT( CAST(SERVERPROPERTY('ResourceVersion') AS VARCHAR(20)),2) as INT) in ('11','12')
    select (physical_memory_KB/1024) as Physical_Mem_MB from sys.dm_os_sys_info
    --else it uses for 2005-08R2
    else select (physical_memory_in_bytes/1024/1024) as Physical_Mem_MB from sys.dm_os_sys_info
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Articles
    Hi Shanky,
    Doesn't work and that's what I meant in my initial post..when I run that code against a SQL 2012 instance, it parses fine but when I execute it I get:
    Msg 207, Level 16, State 1, Line 6
    Invalid column name 'physical_memory_in_bytes'.

Maybe you are looking for

  • I am trying to upgrade my iBook

    I have an old iBook that used to have mac osx 10.2.8, but now I just downgraded to 9.1 because there was a password i couldn't get past. Now I want to upgrade back up to 10.2.8, but I can't I tried the official cds, but the os said it isn't readable.

  • Re: Schedule a WEBI report once the BW process chain loading is completed

    Hello Guys, I want to schedule a webi report once the process chain in bw is sucessfully completed .Did any one face this situation before ? is it possible to trigger a event from bw to webi and schedule a webi report to end users once the process ch

  • Is this a bug? about multimap

    code: #include <map> int main() std::multimap<int, float> coll; coll.insert(std::make_pair(2, 22.3f)); return 0; compile with CC command . get some error compile with g++ command. OK why? Best D.Y

  • WLS managed server startup failure due to JMS Diagnostics Err BEA-320127

    We have started to expereince problems starting a weblogic managed SOA server. The server fails to start with the following JMS related error: <Error> <Diagnostics> <BEA-320127> <An error occurred while generating Image Source JMS as part of the diag

  • Premiere Pro 2014.1 Update?

    Hello! We are attempting to update Premiere Pro to 2014.1. However, CC is telling us that 2014.0 is the most up-to-date version we can install. Any suggestions? Thanks!