Thursday, November 28, 2013

PL/SQL Runs on the Server, not on the Client

I read in a book that PL/SQL runs on the server, not the client so I decided to check this out. I started a Command prompt on my Windows PC and used a SQL*Plus session to connect to a database on a UNIX server. Then I kicked off the loop below:
 
SQL> ed
Wrote file afiedt.buf
 
  1  declare
  2   a number;
  3  begin
  4   for b in 1..1000000000
  5    loop
  6    a := a + 1;
  7    end loop;
  8* end;
SQL> /
 
After it had been running for a while, I looked at the CPU usage on the Windows PC but it was hardly showing any at all (as usual, click on the image to enlarge it and bring it into focus):


The server, on the other hand, was showing over 95% of the CPU was being used for this one task so it seems that the book was right: 

Oracle 9: ps aux|more
USER            PID %CPU %MEM   VSZ  RSS TTY      S    STARTED         TIME COMMAND
oracle       503287 95.4  0.5  299M 4.7M ??       R    18:34:17     4:52.64 oracleLIVDPT1 (LOCAL=NO)

1 comment:

rishabh sethi said...

Very Interesting.