Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Find out how many CPUs ?

Re: Find out how many CPUs ?

From: Charles Hooper <hooperc2000_at_yahoo.com>
Date: 29 Sep 2006 10:41:49 -0700
Message-ID: <1159551709.292738.130220@b28g2000cwb.googlegroups.com>


DA Morgan wrote:
> Charles Hooper wrote:
> > klabu wrote:
> >> 10g
> >> Is there a way/view to find out from WITHIN Oracle (i.e. No access to
> >> OS)
> >> How many CPUs on the server ?
> >>
> >> thx
> >
> > V$OSSTAT:
> >
> > SELECT
> > MAX(DECODE(STAT_NAME,'NUM_CPUS',VALUE,1)) CPUS,
> > MAX(DECODE(STAT_NAME,'NUM_CPU_CORES',VALUE,1)) CPU_CORES,
> > MAX(DECODE(STAT_NAME,'BUSY_TIME',VALUE,0)) BUSY_TIME,
> > MAX(DECODE(STAT_NAME,'IDLE_TIME',VALUE,0)) IDLE_TIME,
> >
> > (MAX(DECODE(STAT_NAME,'BUSY_TIME',VALUE,0))/MAX(DECODE(STAT_NAME,'NUM_CPUS',VALUE,1)))/24/
> > 3600/100 BUSY_DAYS,
> >
> > (MAX(DECODE(STAT_NAME,'IDLE_TIME',VALUE,0))/MAX(DECODE(STAT_NAME,'NUM_CPUS',VALUE,1)))/24/
> > 3600/100 IDLE_DAYS
> > FROM
> > V$OSSTAT;
> >
> > Charles Hooper
> > PC Support Specialist
> > K&M Machine-Fabricating, Inc.
> >
>
> Wouldn't
> SELECT value
> FROM gv$osstat
> WHERE stat_name = 'NUM_CPUS';
>
> Be a bit more direct?
> --
> Daniel Morgan
> University of Washington
> Puget Sound Oracle Users Group

There is a reason why I posted the code as I did (aside from already having written the SQL code). NUM_CPUS returns the number of virtual CPUs, including in the count hyperthreaded CPUs in addition to the actual core count. NUM_CPU_CORES returns the number of actual CPU cores reported by the operating system. The OP did not indicate which was of interest, so both results will be returned on a single row, along with a rough calculation of how busy the CPUs have been.

You probably are correct that selecting from GV$OSSTAT is more direct than selecting from V$OSSTAT. My memory is a bit fuzzy. Isn't there another layer of views that the database needs to drill through to reach the data when accessing through V$OSSTAT, rather than GV$OSSTAT?

Charles Hooper
PC Support Specialist
K&M Machine-Fabricating, Inc. Received on Fri Sep 29 2006 - 12:41:49 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US