Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can this bad query be improved?

jmft2012Feb 26 2013 — edited Mar 8 2013
Db:11.2.0.3
We have a 3rd party app and the web app runs very slow. We want to make the 3rd party to fix the issue. for the
app login process, I did an AWR , found the problem query it runs 10 mins. Then I did the sqltrace
here is it:
select clndr_id , count(*) 
from
 task where (clndr_id = :"SYS_B_0") group by clndr_id union select clndr_id , 
  count(*) from project where (clndr_id = :"SYS_B_1") group by clndr_id


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.00          0          0          0           0
Execute      1      0.01       0.00          0          0          0           0
Fetch        2     53.32     612.03      81650      58920          0           2
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4     53.34     612.04      81650      58920          0           2

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 34  (PX)
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         2          2          2  SORT UNIQUE (cr=58923 pr=81650 pw=22868 time=113329109 us cost=58277 size=24 card=2)
         2          2          2   UNION-ALL  (cr=58923 pr=81650 pw=22868 time=113329001 us)
         1          1          1    SORT GROUP BY NOSORT (cr=58330 pr=81070 pw=22868 time=104312437 us cost=58128 size=7 card=1)
   5589739    5589739    5589739     VIEW  index$_join$_003 (cr=58330 pr=81070 pw=22868 time=619784236 us cost=57240 size=38875249 card=5553607)
   5589739    5589739    5589739      HASH JOIN  (cr=58330 pr=81070 pw=22868 time=617373467 us)
   5590158    5590158    5590158       INDEX RANGE SCAN NDX_TASK_CALENDAR (cr=21676 pr=21676 pw=0 time=113637058 us cost=11057 size=38875249 card=5553607)(object id 24749)
   6673774    6673774    6673774       INDEX FAST FULL SCAN NDX_TASK_PROJ_RSRC (cr=36651 pr=36526 pw=0 time=213370625 us cost=21921 size=38875249 card=5553607)(object id 217274)
         1          1          1    SORT GROUP BY NOSORT (cr=593 pr=580 pw=0 time=9016527 us cost=149 size=17 card=1)
    136390     136390     136390     INDEX FAST FULL SCAN NDX_PROJECT_CALENDAR (cr=593 pr=580 pw=0 time=165434 us cost=132 size=2315876 card=136228)(object id 154409)


Rows     Execution Plan
-------  ---------------------------------------------------
      0  SELECT STATEMENT   MODE: ALL_ROWS
      2   SORT (UNIQUE)
      2    UNION-ALL
      1     SORT (GROUP BY NOSORT)
5589739      TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF 'TASK' 
                 (TABLE)
5589739       INDEX   MODE: ANALYZED (RANGE SCAN) OF 
                  'NDX_TASK_CALENDAR' (INDEX)
5590158     SORT (GROUP BY NOSORT)
6673774      INDEX   MODE: ANALYZED (RANGE SCAN) OF 
                 'NDX_PROJECT_CALENDAR' (INDEX)


Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       2        0.00          0.00
  Disk file operations I/O                        2        0.00          0.00
  db file sequential read                     22235        1.61        138.66
  direct path write                            1620        3.25        177.42
  db file scattered read                       2313        1.89        238.98
  direct path read                              385        1.72         19.52
  SQL*Net message from client                     2        0.11          0.21
Please make your comments.
Thanks in Advance.
This post has been answered by Jonathan Lewis on Mar 4 2013
Jump to Answer

Comments

unknown-951199

>Anyone has any ideas?

a problem exists

content deleted

How do I ask a question on the forums?

https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360002

Ivica Arsov

Hi,

You need to provide more detail information ... from this I see shutdown initiated by user.

Ivica

jgarry

What platform are you on?  Do you have a cron doing a bounce for backups?  Does it happen at the same time?  Are you on a VM?

BPeaslandDBA

Occasionally, it automatically shuts itself down

Shutting down instance (immediate)

The two statements above are in direct opposition to itself. The database will not automatically shut itself down and the second line shows a SHUTDOWN IMMEDIATE was explicitly requested. Now maybe you didn't do the requesting, but someone or better yet...something made the request. Check for scheduled batch jobs that are performing a cold backup...or one that the previous DBA implemented to perform a regular restart "just to clear things up".

Cheers,

Brian

Aman....

Like other members have mentioned, without an explicit attempt, it's not possible. So check for any scheduled jobs, review the auditing logs and ask around if someone is having itchy fingers.

Aman....

Harmandeep Singh

Just two cents, From the timings of shutdown and startup, as others said, look at various logs and cron jobs

Regards,

Harman

tvCa-Oracle

There's different ways to find out, one is to start changing passwords. Of course, using the pre-designed method.

It could be an external system, reaching out to your server.

Could be a lot, really. But just check Crontab

Vsevolod Afanassiev

Is it running in noarchive,log mode? May be it gets shut down for cold backup?

Is there a time gap between shutdown and startup?

What's about the server where the database is running? Does it stay up or it also gets restarted? On UNIX user "uptime" to determine when a server was restarted.

User726571-Oracle

Hi All,

Thank you very much for all of the replies. My sincere apologies for not fully complying with all forum rules and etiquettes.

This is a QE automatic  environment where the problem is seen occasionally (not always).

It cannot be reproduced in development or other manually driven QE environment.

Here is the information on the automatic process and its environment.

* It accepts a job request with all necessary parameters from a user

* it arbitrarily allocates a host machine - a Linux (OLE5/6) image, from a pool of hosts

* It installs the DB (oracle 11.2.0.1.0) on the that host

* It installs the applications/products on the same host

* It runs all kinds of test scripts that include some selenium tests for UI implemented using Oracle ADF

* It occasionally fails only on selenium tests

* After completion of the job, it creates a job report on partially or fully successful tests.

* The host image is available for a few hours after the job completion notification

* Users have access to DB log files and application log files for a few hours.

* The host image is then retuned to the pool of hosts and thereafter no further access to the host is possible.

Regards,

-ab

jgarry

Well, in the absence of other errors, the likelihood is either there is something wrong with the script, or somehow it is getting run twice without actually creating a new VM (I'm guessing however it is created assumes it is not in use), or you have some backup routine for the VM that shuts down the db in conflict with the test, or something else is wrong.

I have seen situations where VMs run out of resources and restart, leaving old ones hanging, but that depends on the VM.

1 - 10
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 5 2013
Added on Feb 26 2013
40 comments
862 views