Skip to content
Keep Learning Keep Living
Keep Learning Keep Living

Tag: add hint

Long Running Query by OCI Performance Hub

Mustafa Kalaycı, 2026-01-27

Hi, We discovered that one of the query run by OCI database management is taking too long and consume a lot of resources. Query is basically getting tablespace information via AWR data but due to some optimization issues it chooses very interesting execution plan. Here is the query:

Oracle PL/SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
WITH latest_snap_id AS (
    SELECT
        snap_id,
        dbid
    FROM
        (
            SELECT
                MAX(snap_id) snap_id,
                dbid
            FROM
                dba_hist_snapshot
            WHERE
                ( end_interval_time - snap_timezone ) > ( sys_extract_utc(systimestamp) - INTERVAL '1' DAY )
            GROUP BY
                dbid
        )
    WHERE
        ROWNUM = 1
), tb_usage as (
    SELECT
        tablespace_name,
        contents,
        round((tablespace_size * blocksize) /(1024 * 1024 ), 4)   as  allocated_space,
        round((tablespace_usedsize * blocksize) /(1024 * 1024 ), 4) as used_space
    FROM
        dba_hist_tbspc_space_usage tb_usage,
        sys.ts$        all_tbs,
        dba_tablespaces dba_tbs,
        latest_snap_id
    WHERE
      ts# = tablespace_id
      AND tb_usage.snap_id = latest_snap_id.snap_id
      and tb_usage.dbid = latest_snap_id.dbid
      AND dba_tbs.tablespace_name = all_tbs.name
)
SELECT
    round(SUM(t.allocated_space)/1024, 2) AS "StorageAllocated",
    round(SUM(t.used_space)/1024, 2) AS "StorageUsed"
from
    tb_usage t
having
        count(*) > 0

What…

Continue Reading

Recent Posts

  • Long Running Query by OCI Performance Hub
  • 26ai Alert Log Size
  • What Should Change After Base DB System Clone
  • Using MFA While Logging into the Oracle Database
  • 2 of Most Practical New Features on 23.9

Recent Comments

  1. Revathy Rangachari on How to call a Web Soap Service or API from PLSQL
  2. Mustafa on How to call HTTPS Url Without SSL Wallet in 19c
  3. Donatas on How to call HTTPS Url Without SSL Wallet in 19c
  4. Mustafa on 3 Ways to Migrate a Non-CDB Database to a PDB
  5. ulises lazarini on 3 Ways to Migrate a Non-CDB Database to a PDB

Archives

  • January 2026
  • November 2025
  • August 2025
  • July 2025
  • June 2025
  • April 2025
  • November 2024
  • July 2024
  • April 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • October 2021
  • September 2021
  • August 2021
  • April 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • July 2019
  • June 2019
  • May 2019
  • March 2019
  • February 2019
  • June 2018

Categories

  • 11g
  • 12c
  • 18c
  • 19c
  • 21c
  • 23ai
  • 26ai
  • Administration
  • Cloud
  • Compression
  • Development
  • Materialized View
  • Multi-tenant
  • Performance
  • Security
  • SQL / PLSQL
  • Uncategorized
  • Undocumented
  • Useful Scripts
©2026 Keep Learning Keep Living | WordPress Theme by SuperbThemes