Question about the inconsistent results when you query v$ sqlarea

Good evening

I do an exercise on threads that consume too much CPU to find and why.

I have the following (bad code) running in the session from a client to create a problem to diagnose:
USER is "SCOTT"
SQL> declare
  2    l_date  date;
  3  begin
  4    for i in 1..10000000 loop
  5      select sysdate into l_date from dual;
  6    end loop;
  7  end;
  8  /
In another session, logged in as SYS, I execute the following query:
col sid         format 9999
col serial#     format 9999999
col ospid       format a8
col sql_text    format a40
col sql_cn      format 9999

select s.sid
     , s.serial#
     , p.spid                   ospid
     , q.sql_text
     , s.sql_child_number       sql_cn
  from v$process p
     , v$session s
     , v$sqlarea q
 where p.addr = s.paddr
   and s.sql_id = q.sql_id(+)
   and p.spid = &os_process_id;
The results I get from the above query vary as shown below:
SQL> @tcpu
Enter value for os_process_id: 1104
old  11:    and p.spid = &os_process_id
new  11:    and p.spid = 1104

  SID  SERIAL# OSPID    SQL_TEXT                                 SQL_CN
----- -------- -------- ---------------------------------------- ------
   31     8564 1104     SELECT SYSDATE FROM DUAL                      0

SQL> @tcpu
Enter value for os_process_id: 1104
old  11:    and p.spid = &os_process_id
new  11:    and p.spid = 1104

  SID  SERIAL# OSPID    SQL_TEXT                                 SQL_CN
----- -------- -------- ---------------------------------------- ------
   31     8564 1104     declare   l_date  date; begin   for i in      0
                         1..10000000 loop     select sysdate int
                        o l_date from dual;   end loop; end;
Is: why is it that sometimes the result of the query shows that the "SELECT SYSDATE FROM DUAL" and other times it shows the entire text of PL/SQL? I would have guessed that SQL_TEXT content would remain constant during execution of the block of code - that's a wrong assumption?

Thank you for your help,

John.

Hello
There's a thing in the execution of PL/SQL which is called context switching, your PL/SQL is executed by PL/SQL engine and when there is a SQL in Pl/SQL, it is performed by the SQL engine and it runs separately and as a result some time when you ask, the execution pointer is on your PL/SQL for loop and some times it is the select statement.

Salman

Tags: Database

Similar Questions

  • Question about the rollback segment when you perform the update

    Undo segment is to keep data ACI (not D). I read that it taken from the book of certification, when the update is running, all the other session will be redirected to cancel the segment to get the original version of the data. Is the rollback segment just a copy of the original version of the data? Or it's the query to return data to the original version?

    For example, the original data are:

    ID name address
    1KevinToronto

    Then I run the update query:

    update user name = 'Tom' where id = 1;

    What is in the segment of cancellation then?

    There ' 1, Kevin, Toronto'.

    or

    "update users set name = 'Kevin' where id = 1"?

    Thank you

    Kevin

    da5515c1-7630-4449-8c7c-e27665cec5c6 wrote:

    Undo segment is to keep data ACI (not D). I read that it taken from the book of certification, when the update is running, all the other session will be redirected to cancel the segment to get the original version of the data. Is the rollback segment just a copy of the original version of the data? Or it's the query to return data to the original version?

    For example, the original data are:

    ID name address
    1 Kevin Toronto

    Then I run the update query:

    update user name = 'Tom' where id = 1;

    What is in the segment of cancellation then?

    There ' 1, Kevin, Toronto'.

    or

    "update users set name = 'Kevin' where id = 1"?

    Thank you

    Kevin

    This is another UPDATE statement that will set back to the original value NAME; which can be used to RESTORE the DML.

  • Questions about privacy and security when you use Safari for Windows

    I have Itunes + Quick Time Player installed to download music and some time ago I had the opportunity to download Safari for Windows.  I used it a few times, just out of curiosity, and I noticed that it is much faster than IE7, so I plan to use it regularly, but before that, I have a few questions:

    -someone at - it tested (or uses) Safari for Windows, and what are your results?

    -What is save to use as Firefox or Opera, both recommended as alternative by our experts at the HijackThis forum?

    -the programs that I installed (Online Armor firewall, AVG 8.0 suite, MBAM with protection in real time enabled RogueRemover Pro with immune protection enabled, WinPatrol, SpywareBlaster) offer the same protection when you use Safari for browsing?

    Thanks a lot already for your answers, Advisor or thoughts on this issue.

    Mona.

    Inspiron 1501

    Win XP - SP3

    Message edited by mona7865 on 08/07/2008 06:19

  • InvalidProperty when you info.vmfs the data store when you query properties

    When I try to interview with a specification of property to store data as below, it throws an exception.

    PropertySpec pdsspec = DataObjectFactory.newInstance (PropertySpec.class);

    TypeName DatastoreType = TypeName.forClass (Datastore.class);

    pdsspec.setType (DatastoreType);

    pdsspec.setAll (Boolean.FALSE);

    pdsspec.setPathSet (new String() {"host", "info.name", "summary.url", "summary.capacity", "summary.freeSpace", "info.vmfs.type"});

    I discovered that info.vmfs.type is originally the InvalidProperty exception. any idea? No work around?

    Thank you

    Vincent

    Hello

    Yes you are right, you must first get the instance of 'info' and then get properties.

    Another approach for the property 'type' store data during extraction is to use 'summary.type' in the setPathSet. This extract the type of the data store.

    I hope this helps.

    -Angela

  • Questions about the Windows Feedback program Fullfillment

    When will I know if my fullfillment of windows feedback program is over, that I have installed on my PC?

    Hello mpic16,

    If you have questions about the Windows feedback program, you will need to respond here.
    https://WFP.Microsoft.com/welcome.aspx

    You can send an email to: * e-mail address is removed from the privacy *.

    They would be better able to answer your questions and concerns.

    Sincerely,

    Marilyn
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • How can I change my HTTPS thing, so it isn't always pop up and ask questions about the sites Web secure when I play some games?

    Feel free to change the title

    How can I change my HTTPS thing, so it isn't always pop up and ask questions about the sites Web secure when I play some games?

    You're talking about Facebook?

    Try the gyration of the Secure Browsing

    http://www.Facebook.com/help?page=1079

  • An error occurred when DNS was questioned about the resource record (SRV) service location used to locate a domain controller Active Directory (AD DC) for the domain 'HAMI. LOCAL ".

    An error occurred when DNS was questioned about the resource record (SRV) service location used to locate a domain controller Active Directory (AD DC) for the domain 'HAMI. LOCAL ".

    The error was: "an existing connection was to be closed by the remote host".
    (0 x 00002746 WSAECONNRESET error code)

    The query was for the SRV record for _ldap._tcp.dc._msdcs. HAMI. LOCAL

    Hello

    Your question of Windows 7 is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNet public. Please post your question in the Forums TechNet Windows 7 Technet.

    Here is the link:
    http://social.technet.Microsoft.com/forums/en-us/w7itpronetworking/threads

    Hope this helps

  • With the help of Photoshop CC on my MacBook Pro (bought a few months ago)... The question I have is that under the filter options, when you select made... There is no option use lighting effects... any suggestions

    With the help of Photoshop CC on my MacBook Pro (bought a few months ago)... The question I have is that under the filter options, when you select made... There is no option use lighting effects... any suggestions?

    Hello

    Please make sure that you work in 8 bits/channel and RGB mode. (Under Image > Mode > Select RGB and 8-bit per channel) lightning effects only works in this mode.

    Also in preferences > Performance > "Use Graphics Processor" must be checked.

    ~ Assani

  • Question Basic setting, ask questions about the buffer cache

    Database: Oracle 10g
    Host: Sun Solaris, 16 CPU server



    I look at the behavior of some simple queries that I start the tuning of our data warehouse.

    Using SQL * more and AUTOTRACE, I ran this query two times in a row

    SELECT *.
    OF PROCEDURE_FACT
    WHERE PROC_FACT_ID BETWEEN 100000 AND 200000

    He finds the index on PROC_FACT_ID and conducted an analysis of the range of indexes to access the data in the table by rowid. The first time, that it ran, there are about 600 physical block reads as data in the table were not in the buffer cache. The second time, he had 0 physical block reads, because they were all in the cache. All this was expected behavior.

    So I ran this query twice now,

    SELECT DATA_SOURCE_CD, COUNT (*)
    OF PROCEDURE_FACT
    DATA_SOURCE_CD GROUP

    As expected, he made a full table scan, because there is no index on DATA_SOURCE_CD and then chopped the results to find the different DATA_SOURCE_CD values. The first run had these results

    compatible gets 190496
    physical reads 169696

    The second run had these results

    compatible gets 190496
    physical reads 170248


    NOT what I expected. I would have thought that the second run would find many of the blocks already in the cache of the pads of the first execution, so that the number of physical reads would drop significantly.

    Any help to understand this would be greatly appreciated.

    And is there something that can be done to keep the table PROCEDURE_FACT (the central table of our star schema) "pinned" in the buffer cache?

    Thanks in advance.

    -chris Curzon

    Christopher Curzon wrote:
    Your comment about the buffer cache used for smaller objects that benefit is something that I asked about a good deal. It sounds as if tuning the buffer cache will have little impact on queries that scan of entire tables.

    Chris,

    If you can afford it and you think it is a reasonable approach with regard to the remaining segments that are supposed to benefit the buffer cache, you can always consider your segment of table with 'CACHE' that will change the behavior on the full of a broad sector table scan (Oracle treats small and large segments differently during the execution of table scans complete regarding the cache of) marking stamps, you can override this treatment by using the CACHE. NOCACHE keyword) or move your table of facts to a DUNGEON hen establishing a (ALTER SYSTEM SET DB_KEEP_CACHE_SIZE = ), modify the segments (ALTER TABLE... STORAGE (USER_TABLES KEEP)) accordingly and perform a full table scan to load blocks in the cache of the DUNGEON.

    Note that the disadvantage of the approach of the KEEP pool is that you have less memory available for the default buffer cache (unless you add more memory on your system). When an object to mark as being cached is always is in competition with other objects in the cache buffers by default, so it could still be aged out (the same applies to the pool of DUNGEON, if the segment is too large or too many segments are allocated age blocks out as well).

    So my question: How can I get for a parallel analysis on queries that use a table scan complete such as what I posted in my previous email? It is a question of the provision of the "parallel" indicator, or is it an init.ora parameter I should try?

    You can use a PARALLEL hint in your statement:

    SELECT /*+ PARALLEL(PROCEDURE_FACT) */ DATA_SOURCE_CD, COUNT(*)
    FROM PROCEDURE_FACT
    GROUP BY DATA_SOURCE_CD;
    

    or you could mark an object as PARALLEL in the dictionary:

    ALTER MATERIALIZED VIEW PROCEDURE_FACT PARALLEL;
    

    Note that since you have 16 processors (or 16 cores that resemble Oracle 32? Check the CPU_COUNT setting) the default parallel degree would be usually 2 times 16 = 32, which means that Oracle generates at least 32 parallel slaves for a parallel operation (it could be another set of 32 slaves if the operation for example include a GROUP BY operation) If you do not use the PARALLEL_ADAPTIVE_MULTI_USER parameter (which allows to reduce the parallelism if several parallel operations running concurrently).

    I recommend to choose a lesser degree parallel to your default value of 32 because usually you gain much by such a degree, then you can get the same performance when you use lower a setting like this:

    SELECT /*+ PARALLEL(PROCEDURE_FACT, 4) */ DATA_SOURCE_CD, COUNT(*)
    FROM PROCEDURE_FACT
    GROUP BY DATA_SOURCE_CD;
    

    The same could be applied to the paralleling of the object:

    ALTER MATERIALIZED VIEW PROCEDURE_FACT PARALLEL 4;
    

    Note When defining the object of many operations in PARALLEL will be parallelisee (DML even can be run in parallel, if you enable dml parallel, which has some special restrictions), so I recommend to use it with caution and begin with an explicit indication in those statements where you know that it will be useful to do.

    Also check that your PARALLEL_MAX_SERVERS is high enough when you use parallel operations, which should be the case in your version of Oracle.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • Question about the menu item displays do not correctly the status of 'active '.

    Hello

    I've reproduced for purposes of training "Influence," tutorial site

    and my questions are the following:

    As you can see on the site

    Homepage 

    (1) the order of top menu contact us, has the same features as the other components (speakers, time and place) - see picture attached.

    However, when the user clicks about us contact.

    the menu item is not barred to the outside like any other.

    I checked the condition of the assets is correct.

    The anchor link is placed on the foot of page, designed on the page A-master separately from the Home Page.Active.JPG

    I tried to place the anchor to the Home Page at the last point before the beginning of footer, but no result.

    (2) also if you do a simple test, you will see that by clicking on the heading "Contact us", the menu Time & Place is highlighted

    and if you click on the 'Top' menu, or if you are in "Time and place" content and you click on 'Top', the 'Speakers' menu is also highlighted.

    Please note that this behavior is also indicated to the site of origin INFLUENCE ...

    What I am doing wrong?

    BR

    Nektarios

    Replied here: https://forums.adobe.com/thread/2063776

  • Questions about the export of PDF with India CS5.5

    Hey all,.

    A few questions about the export to PDF of the most recent version of India.

    First of all, I noticed it seems to take much more time to access a PDF file. Any suggestions about how to speed up the process? It took 8 minutes to generate a PDF low resolution (for printing) of a document of 24pp with placed images and vector graphics. Wow, that's a long wait, especially for evidence.

    Second, the background task... If I get it will make this PDF of 8 minutes and then more work on the document, which is exactly in the PDF? Usually, I have save before making a PDF or printing. Thus, the latest version is saved which will be in the PDF?

    (Either incidentally, this ability to work on the doc while generating a PDF file seems kind of weird. Generally, we do a PDF for proofing, or even for printing, when any changes have been made and that everything is "final". Therefore, I see no advantage in being able to work on my document while it is making a PDF file, I am probably once your revisions for the moment. I must say that I like the progress bar that you get when you perform an interactive PDF, as you know that you can not work on the document when it is on the screen...)

    Thank you as always.

    Good, people. Wanted to just follow this and post my results. It turns out that the problem is somewhere in the Illustrator file. I never had the time to guess what work plan was the culprit. Other India files PDF files is transparent and not a lot of time.

    No resolution, unfortunately, just good to know that it is not all India files on my system. Phew!

    THANK YOU for your advice.

  • A question about the REEL in sqlplus command

    Hi all


    I have a question about the order of the COIL and I would be grateful if you could kindly give me a helping hand. Consider the following sql script.
    SPOOL result.txt
    SELECT * FROM mytable;
    SPOOL OFF;
    It works pretty well, and all the contents of the table "MyTable" is exported to the textfile "result.txt". However, sqlplus also prints the number of lines
    Print after each query. So after you run this script, the end of the file, I always have a line like
    ...
    "20541 lines returned"
    How can I avoid this line (the number of returned rows) in my output file?


    Thanks in advance,
    Dariyoosh

    Type this command prior to winding.

    set feedback off
    

    Kind regards
    Prazy

  • A few questions about the Satellite A100 PSAANE

    Hi friends,

    I have a Toshiba Satellite A 100 - PSAANE with Vista Home Basic preinstalled in it.
    Now, I have a few questions... I mention below: -.

    (1) if I want to format my laptop, I need a CD to install for Vista Home basic... then I don't have this Toshiba CD when I bought the laptop. So how do? question: How can I format it?

    (2) can I change my Vista Home Basic to windows XP? I think it's much faster than this one. is it advisable?

    (3) I have a GB of RAM in the laptop. Increase the RAM? I think that my laptop has become to slow down. is it advisable?

    (4) and on my screen, everytime I try to change my profile screen to windows Classic view, my screen begins to blink. and after a while, the screen turns off. So I can't change that. I put the color scheme of windows vista only. What to do about that?

    Please help me friends. Thanks in advance.

    Kind regards
    Perkins

    Hello

    Here, a few questions about the number:

    (1) usually, you should get the Vista Toshiba Recovery DVD. If you didn t receive this DVD then you can order it here https://backupmedia.toshiba.eu/landing.aspx or you could install the disc of Microsoft Vista.

    (2) of course, you can do this. I think that Win XP drivers can be downloaded from the Toshiba driver page.

    (3) Yes, you can upgrade the RAM. For more information, see your manual or search on this forum for similar topics

    (4) maybe it s associated with the graphics driver. Check if you can update. I would recommend additional check if you are using the latest version of the BIOS

    Welcome them

  • Re: Several questions about the recovery of the Satellite L750 features

    I have several questions about the recovery of Satellite L750 features available to it. Any help and answers would be useful.

    (1) when I started the laptop first, he asked me to create a recovery CD incase I need to reinstall the operating system. But he also said that he built in the recovery partition, so therefore, I have to make a recovery cd or not?

    (2) will be the recovery CD is exactly the same as the recovery on the system partition?

    (3) is the partion of CD or recovery includes all the integrated software pre-installed with the laptop?

    (4) also in the device manage management it shows watch partion recovery but it is empty, is it true?

    (5) in the second partition (drive D) system, he has a record with what looks like the recovery of files and folders. Is it safe to move/remove it?

    Hello

    I'll try to provide answers:
    1 - to ensure that everything works perfectly you don t need these discs, but if something goes wrong with the HARD drive you will not be able to do anything. When you have the recovery DVDs, you will still be able to install the recovery image and once again the factory settings. So my advice to you is: create these discs as soon as possible. Use only on DVD-R media and buy products of high quality (TDK or Verbatim).
    2 - Yes.
    3 - Yes.
    4 - No. Don t be confused with this.
    5. in a first time create restore DVD, and later you can do what you want. I put t know which files mean you but don t touch anything before that of the recovery disks to be created.

    In the past, many people have been experimenting with the structure of HARD drive and partitions and later was surprised when installing disk recovery HARD has been damaged. Don t make the same mistake.

    If you have any other questions you are welcome.

  • two questions about the scattered images secure

    I created an image that is secure and encrypted for sensitive documents.

    I have two questions:

    1. when I use the disk (if it is up, open and available), and I want to add something to it, I usually drag the file everywhere where it is currently in its destination folder in the sparse image control.  But it automatically makes a copy - with the same name (not with a '-1' ever, not with a suffix 'copying' or 'alias').  Which defeats the purpose and makes things complicated - I find myself comparing what is in each location to make sure it's in the sparse image and then it makes me nervous to delete the original.  Why it does this and how can I change such as dragging a file in a secure location gives there is not that a second copy of it left in an UNsecure location?

    2. I'm using Time Machine backup drive sitting on my desk (and a separate utility for monthly clones on a different backup disk).  Automatically makes Time Machine backup the content of the rare picture even if the safe drive is not mounted, open and available?  I hope not, because that would undermine the usefulness of having a backup disk on my desktop running of ordinary Time Machine backups, but find it me just that all the steps I take of course I do not lose any data may be so overprotective I have thought/hoped.

    Sous_forme_d' addendum, I'll check my clone, but as I put this out there, I wonder if SuperDuper!, my application of cloning is cloning automatically secure disk content, so... like the thoughts of anyone about it if it's an application that they use).

    FYI: I'm running 10.11.2

    Thank you.

    (1) by default, OS X makes a copy with the overcoming of the limits of volume and moves when in the same volume.

    You can reverse this behavior by holding down the command key when you drop. You will see the insignia of the icon changes (green + for copy, empty for move).

    (2) Time Machine will return to the top of the image 'file', but only when it is unmounted. I do not think that it automatically includes the volume mounted, but I would like to check and add to the exclusion list.

Maybe you are looking for