Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9164789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:45:54+00:00 2026-06-17T14:45:54+00:00

I have a query (below). The explain plan shows high CPU utilization which has

  • 0

I have a query (below). The explain plan shows high CPU utilization which has also caused downtime in our lab. So it possible to tube this query further? What should i do to tune it?

FYI, mtr_main_a, mtr_main_b, mtr_hist contain huge no of records may be 10 millions or more.

SELECT to_char(MAX(mdt), 'MM-DD-RRRR HH24:MI:SS')
FROM   (
           SELECT MAX(mod_date - 2 / 86400) mdt
           FROM   mtr_main_a
           UNION
           SELECT MAX(mod_date - 2 / 86400) mdt
           FROM   mtr_main_b
           UNION
           SELECT MAX(mod_date - 2 / 86400) mdt
           FROM   mtr_hist@batch_hist
       )
/

Explain plan is as below

Execution Plan
----------------------------------------------------------
Plan hash value: 1573811822

-------------------------------------------------------------------------------------------------------------
| Id  | Operation              | Name       | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Inst   |IN-OUT|
-------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT       |            |     1 |     9 |       | 79803   (1)| 00:18:38 |        |      |
|   1 |  SORT AGGREGATE        |            |     1 |     9 |       |            |          |        |      |
|   2 |   VIEW                 |            |     2 |    18 |       | 79803   (1)| 00:18:38 |        |      |
|   3 |    SORT UNIQUE         |            |     2 |    17 |    77M| 79803   (2)| 00:18:38 |        |      |
|   4 |     UNION-ALL          |            |       |       |       |            |          |        |      |
|   5 |      SORT AGGREGATE    |            |     1 |     8 |       | 79459   (1)| 00:18:33 |        |      |
|   6 |       TABLE ACCESS FULL| MTR_MAIN_A |  5058K|    38M|       | 67735   (1)| 00:15:49 |        |      |
|   7 |      SORT AGGREGATE    |            |     1 |     9 |       |   344   (1)| 00:00:05 |        |      |
|   8 |       TABLE ACCESS FULL| MTR_MAIN_B |     1 |     9 |       |   343   (1)| 00:00:05 |        |      |
|   9 |      REMOTE            |            |       |       |       |            |          |  HISTB | R->S |
-------------------------------------------------------------------------------------------------------------

Remote SQL Information (identified by operation id):
----------------------------------------------------

   9 - EXPLAIN PLAN SET STATEMENT_ID='PLUS10294704' INTO PLAN_TABLE@! FOR SELECT
       MAX("A1"."MOD_DATE"-.00002314814814814814814814814814814814814815) FROM "MTR_HIST" "A1" (accessing
       'HISTB' )

Thanks and Regards,
Chandra

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:45:55+00:00Added an answer on June 17, 2026 at 2:45 pm

    You should be able to greatly improve the performance by putting an index on the mod_date columns and changing your query in a way that does the subtraction at the end, after you determined the maximum date:

    SELECT to_char(MAX(mdt) - 2 / 86400, 'MM-DD-RRRR HH24:MI:SS')
    FROM   (
               SELECT MAX(mod_date) mdt
               FROM   mtr_main_a
               UNION
               SELECT MAX(mod_date) mdt
               FROM   mtr_main_b
               UNION
               SELECT MAX(mod_date) mdt
               FROM   mtr_hist@batch_hist
           )
    

    This should get rid of the full table scans.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query which is returning the below explain: id select_type table type
I have this query (shown below) which currently uses temporary and filesort in order
Can someone explain me how below query will work.. i have table called employee
How is it possible to have a good plan in EXPLAIN like below and
I have a query below that I use to retrieve the records not updated
We have the query below. Using a LEFT OUTER join takes 9 seconds to
I have the query below that when run it says that 325 rows were
I have below query I am trying to show message 'No SubSource for this
I have a query like below declare @str_CustomerID int Insert into IMDECONP38.[Customer].dbo.CustomerMaster ( CustomerName
I have an SQL query (below) that essentially takes a student from tbStudents, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.