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

  • SEARCH
  • Home
  • 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 9291441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:38:50+00:00 2026-06-18T20:38:50+00:00

I have a DB2 database with three tables, A, B and C. The database

  • 0

I have a DB2 database with three tables, A, B and C.

The database was created thus:

create database DB alias DB AUTOMATIC STORAGE YES ON /home/db2inst1
using codedeset UTF-8 territory en PAGESIZE 32768

  • Table A is 28 columns wide with 1.8 mill. rows and PID is primary
    key. The columns mostly has int-types, but some are varchar(200-400).
    Index: PID
  • Table B is 7 columns wide with 14 mill. rows and primary key PID_L.
    It also has columns C_SOURCE and ROW_COUNT. Index: PID,C_SOURCE
  • Table C is 20 columns wide with 14 mill. rows and primary key PID_S.
    It also has a column ROLE. Index: PID,PID_S

All tables have the column PID

I need a table which aggregates some info in Table B and C. The query to select the appropriate items is:

SELECT
    T.*,
    (
        SELECT 
            COALESCE(SUM(ROW_COUNT),0)
        FROM 
            C as ITS,
            B as ITL
        WHERE 
            ITS.ROLE = 1
            AND ITS.PID = ITL.PID
            AND ITS.PID_S = ITL.C_SOURCE
            AND ITS.PID = T.PID
    ) AS RR
FROM 
    A as T;

When this query is run, the DB2 server quickly uses about 3Gb memory. Using top, the CPU usage, however, rarely goes beyond 5%, with some jumps into about 13%. The DB2 server is a RedHat6.2 VM, with 4 cores and 2Ghz per core.

I have let this query run for 24 hours without anything seeming to happen. Other queries, like simple selects and many more, work smoothly.

Questions:

  1. Do you have any suggestions for a different, more efficient, query that might accomplish the same thing?
  2. Is it possible that this performance issue has something to do with the configuration of the database?
  • 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-18T20:38:52+00:00Added an answer on June 18, 2026 at 8:38 pm

    i would try the “explain” feature, to see, what db2 is making out of your query

    db2exfmt -d database -e schema -t -v % -w -1 -s % -# 0 -n % -g OTIC

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

Sidebar

Related Questions

DB2 v10.1 database on WINDOWS 7 I have three tables: 1.table Rase id Rases
Database: DB2 v9.5 on AIX Scenario: I have 2 instances- db2inst1 and db2inst2. I
I am using DB2 database and hibernate framework. There are two tables such as
I have table TICKET with 400K records in database (DB2). I wish to create
I am using DB2 database. I have a query like: DELETE FROM MYSCHEMA.MY_TABLE WHERE
I have a db2 database with this charset options: db2 get db cfg for
I have two Database, DB1 and DB2. How can I transfer data of DB1
I have to pull data from a SQL database table to my DB2 table.
I have DB2 table having following structure CREATE TABLE DUMMY ( ID CHARACTER(10) NOT
I have written a DB2 query to do the following: Create a temp table

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.