목차
Oracle X$ tables – Part 1 – Where do they get their data from?
Related Posts
데이터 베이스 MySQL 튜토리얼 Oracle X$ tables – Part 1 – Where do they get their data f

Oracle X$ tables – Part 1 – Where do they get their data f

Jun 07, 2016 pm 03:46 PM
oracle where

Oracle X$ tables – Part 1 – Where do they get their data from? by Tanel Poder Posted on January 10, 2014 It’s long-time public knowledge that X$ fixed tables in Oracle are just “windows” into Oracle’s memory. So whenever you query an

Oracle X$ tables – Part 1 – Where do they get their data from?

by Tanel Poder Posted on January 10, 2014

It’s long-time public knowledge that X$ fixed tables in Oracle are just “windows” into Oracle’s memory. So whenever you query an X$ table, the FIXED TABLE rowsource function in your SQL execution plan will just read some memory structure, parse its output and show you the results in tabular form. This is correct, but not the whole truth.

Check this example. Let’s query the X$KSUSE table, which is used by V$SESSION:

SQL&gt; SELECT addr, indx, ksuudnam FROM x$ksuse WHERE rownum <strong>391513C4</strong>          1 SYS
3914E710          2 SYS
3914BA5C          3 SYS
39148DA8          4 SYS
391460F4          5 SYS
로그인 후 복사

Now let’s check in which Oracle memory region this memory address resides (SGA, PGA, UGA etc). I’m using my script fcha for this (Find CHunk Address). You should probably not run this script in busy production systems as it uses the potentially dangerous X$KSMSP fixed table:

SQL&gt; @fcha <strong>391513C4</strong>
Find in which heap (UGA, PGA or Shared Pool) the memory address 391513C4 resides...

WARNING!!! This script will query X$KSMSP, which will cause heavy shared pool latch contention
in systems under load and with large shared pool. This may even completely hang
your instance until the query has finished! You probably do not want to run this in production!

Press ENTER to continue, CTRL+C to cancel...

LOC KSMCHPTR   KSMCHIDX   KSMCHDUR KSMCHCOM           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
--- -------- ---------- ---------- ---------------- ---------- -------- ---------- --------
<span><strong>SGA</strong></span> 39034000          1          1 permanent memor     3977316 perm              0 00

SQL&gt;
로그인 후 복사

Ok, these X$KSUSE (V$SESSION) records reside in a permanent allocation in SGA and my X$ query apparently just parsed & presented the information from there.

Now, let’s query something else, for example the “Soviet Union” view X$KCCCP:

SQL&gt; SELECT addr, indx, inst_id, cptno FROM x$kcccp WHERE rownum <strong>F692347C</strong>          0          1          1
F692347C          1          1          2
F692347C          2          1          3
F692347C          3          1          4
F692347C          4          1          5
로그인 후 복사

Ok, let’s see where do these records reside:

SQL&gt; @fcha <strong>F692347C</strong>
Find in which heap (UGA, PGA or Shared Pool) the memory address F692347C resides...

WARNING!!! This script will query X$KSMSP, which will cause heavy shared pool latch contention
in systems under load and with large shared pool. This may even completely hang
your instance until the query has finished! You probably do not want to run this in production!

Press ENTER to continue, CTRL+C to cancel...

LOC KSMCHPTR   KSMCHIDX   KSMCHDUR KSMCHCOM           KSMCHSIZ KSMCHCLS   KSMCHTYP KSMCHPAR
--- -------- ---------- ---------- ---------------- ---------- -------- ---------- --------
<span><strong>UGA</strong></span> F6922EE8                       <strong>kxsFrame4kPage</strong>         4124 freeabl           0 00

SQL&gt;
로그인 후 복사

Wow, why does the X$KCCCP data reside in my session’s UGA? This is where the extra complication (and sophistication) of X$ fixed tables comes into play!

Some X$ tables do not simply read whatever is in some memory location, but they have helper functions associated with them (something like fixed packages that the ASM instance uses internally). So, whenever you query this X$, then first a helper function is called, which will retrieve the source data from whereever it needs to, then copies it to your UGA in the format corresponding to this X$ and then the normal X$ memory location parsing & presentation code kicks in.

If you trace what the X$KCCCP access does – you’d see a bunch of control file parallel read wait events every time you query the X$ table (to retrieve the checkpoint progress records). So this X$ is not doing just a passive read only presentation of some memory structure (array). The helper function will first do some real work, allocates some runtime memory for the session (the kxsFrame4kPage chunk in UGA) and copies the results of its work to this UGA area – so that the X$ array & offset parsing code can read and present it back to the query engine.

In other words, the ADDR column in X$ tables does not necessarily show where the source data it shows ultimately lives, but just where the final array that got parsed for presentation happened to be. Sometimes the parsed data structure is the ultimate source where it comes from, sometimes a helper function needs to do a bunch of work (like taking latches and walking linked lists for X$KSMSP or even doing physical disk reads from controlfiles for X$KCCCP access).

And more, let’s run the same query against X$KCCCP twice:

SQL&gt; SELECT addr, indx, inst_id, cptno FROM x$kcccp WHERE rownum <strong>F69254B4</strong>          0          1          1
F69254B4          1          1          2
F69254B4          2          1          3
F69254B4          3          1          4
F69254B4          4          1          5
로그인 후 복사

And once more:

SQL&gt; SELECT addr, indx, inst_id, cptno FROM x$kcccp WHERE rownum <strong>F692B508</strong>          0          1          1
F692B508          1          1          2
F692B508          2          1          3
F692B508          3          1          4
F692B508          4          1          5
로그인 후 복사

See how the ADDR column has changed between executions even though we are querying the same data! This is not because the controlfiles or the source data have somehow relocated. It’s just that the temporary cursor execution scratch area, where the final data structure was put for presentation (kxsFrame4kPage chunk in UGA), just happened to be allocated from different locations for the two different executions.

There may be exceptions, but as long as the ADDR resides in SGA, I’d say it’s the actual location of where the data lives – but when it’s in UGA/PGA, it may be just the temporary cursor scratch area and the source data was taken from somewhere else (especially when the ADDR constantly changes or alternates between 2-3 different variants when repeatedly running your X$ query). Note that there are X$ tables which intentionally read data from arrays in your UGA (the actual source data lives in the UGA or PGA itself), but more about that in the future.

  • Where is LOB data stored?
  • Profiling trace files with preprocessor external tables in 11g and some parallel execution hacking
  • Oracle In-Memory Column Store Internals – Part 1 – Which SIMD extensions are getting…
  • Oracle Exadata Performance series – Part 1: Should I use Hugepages on Linux Database Nodes?
  • When do Oracle Parallel Execution Slaves issue buffered physical reads – Part 2?
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

뜨거운 기사 태그

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

오라클에서 두 날짜 사이의 일수를 계산하는 함수 오라클에서 두 날짜 사이의 일수를 계산하는 함수 May 08, 2024 pm 07:45 PM

오라클에서 두 날짜 사이의 일수를 계산하는 함수

Oracle 데이터베이스 로그는 얼마나 오래 보관됩니까? Oracle 데이터베이스 로그는 얼마나 오래 보관됩니까? May 10, 2024 am 03:27 AM

Oracle 데이터베이스 로그는 얼마나 오래 보관됩니까?

Oracle 데이터베이스 시작 단계의 순서는 다음과 같습니다. Oracle 데이터베이스 시작 단계의 순서는 다음과 같습니다. May 10, 2024 am 01:48 AM

Oracle 데이터베이스 시작 단계의 순서는 다음과 같습니다.

오라클에서 간격을 사용하는 방법 오라클에서 간격을 사용하는 방법 May 08, 2024 pm 07:54 PM

오라클에서 간격을 사용하는 방법

Oracle 데이터베이스 서버 하드웨어 구성 요구 사항 Oracle 데이터베이스 서버 하드웨어 구성 요구 사항 May 10, 2024 am 04:00 AM

Oracle 데이터베이스 서버 하드웨어 구성 요구 사항

Oracle에서 특정 문자의 발생 횟수를 확인하는 방법 Oracle에서 특정 문자의 발생 횟수를 확인하는 방법 May 09, 2024 pm 09:33 PM

Oracle에서 특정 문자의 발생 횟수를 확인하는 방법

오라클에는 얼마나 많은 메모리가 필요합니까? 오라클에는 얼마나 많은 메모리가 필요합니까? May 10, 2024 am 04:12 AM

오라클에는 얼마나 많은 메모리가 필요합니까?

오라클에 두 문자열이 포함되어 있는지 확인하는 방법 오라클에 두 문자열이 포함되어 있는지 확인하는 방법 May 08, 2024 pm 07:00 PM

오라클에 두 문자열이 포함되어 있는지 확인하는 방법

See all articles