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 8861069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:24:30+00:00 2026-06-14T15:24:30+00:00

Attached is a fiddle that lays out my schema with a comment along side

  • 0

Attached is a fiddle that lays out my schema with a comment along side each table to indicate the number of rows in each of the aforementioned tables. The query looks like so, in case the fiddle is blocked:

select distinct cat_name,cat_age, co_cat_owners_id,cat_weight,cs_is_alive,os_is_current, cos_is_current,
      sum(cat_age) over(partition by co_cat_owners_id) running_total
from
   (
         select co.cat_owners_id co_cat_owners_id,
               co.cat_id co_cat_id,
               co.owner_id co_owner_id,
               co.vet_id co_vet_id, 
               cos.is_current cos_is_current,
               os.is_current os_is_current,
               cs.is_alive cs_is_alive,
               cat.name cat_name,
               cat.age cat_age,
               cat.weight cat_weight
         from cat_owners co,
              cat_owner_statuses cos,
              cat_statuses cs,
              cats cat,
              owners o,
              owner_statuses os
         where o.owner_id = co.owner_id
         and cat.cat_id = co.cat_id
         and cos.last_visit >= sysdate - 4/24
    )
where cs_is_alive = '1' 
and (cos_is_current = '1' OR os_is_current='1')
group by cat_name,cat_age,cat_weight,cs_is_alive,os_is_current,co_cat_owners_id,cos_is_current;

In my development environment the explain plan lays out very closely to what is inside the fiddle, in terms of steps, however I do have several steps where Memory size is 15E (exabytes) with a row count of 4000P (petabytes). My question is where along the lines of index creation/bad SQL did I manage to generate a 15 exabyte solution to a problem that should be solvable in far less space and time. I have noticed that tweaking some of the composite index creation steps yields slightly different results, but I am still blocked by an Exabyte space requirement.

NOTE

In case someone in the future doesn’t read all of the comments, running the following function in conjunction with correct joins helped:

analyze table table_name_here compute statistics;
  • 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-14T15:24:32+00:00Added an answer on June 14, 2026 at 3:24 pm

    Your query has 6 tables in the FROM clause but you have only specified two join conditions. OWNERS has 10 million rows, CAT_OWNERS has 120 million rows so I’m guessing that the join produces 120 million rows. Then you join to CATS which has 1 million rows so I’m assuming at this point that you’ve got 120 million rows. From there, however, you have no more join conditions. So your 120 million row interim result gets cartesian joined with the 500 million row CAT_OWNER_STATUSES table which produces 120 million * 500 million rows which is 60 quadrillion rows. Cartesian join that to the 10 million row CAT_STATUSES table and you end up with 60 quadrillion * 10 million rows and now we’re up to 6 * 10^23 rows. And then you Cartesian join that again to OWNER_STATUSES which has 90 million rows which gives you 5.4 * 10^31 rows. If you want a reasonable number of results, you are going to need to specify additional join conditions to avoid the Cartesian products.

    It is, unfortunately, a bit hard to follow the data model in your fiddle because there appear to be a number of potentially contradictory ways to join your tables together. CAT_VETS maps cats to vets but so does CAT_OWNERS, for example. Without data and expected results, that makes it very tough to guess at how the tables should be joined. My guess is that you want something like this modified fiddle

    select distinct cat_name,cat_age, co_cat_owners_id,cat_weight,cs_is_alive,os_is_current, cos_is_current,
          sum(cat_age) over(partition by co_cat_owners_id) running_total
    from
       (
             select co.cat_owners_id co_cat_owners_id,
                   co.cat_id co_cat_id,
                   co.owner_id co_owner_id,
                   co.vet_id co_vet_id, 
                   cos.is_current cos_is_current,
                   os.is_current os_is_current,
                   cs.is_alive cs_is_alive,
                   cat.name cat_name,
                   cat.age cat_age,
                   cat.weight cat_weight
             from cat_owners co,
                  cat_owner_statuses cos,
                  cat_statuses cs,
                  cats cat,
                  owners o,
                  owner_statuses os,
                  cat_vets cv,
                  owner_vets ov
             where o.owner_id = co.owner_id
             and cat.cat_id = co.cat_id
             and cos.cat_owners_id = co.cat_owners_id
             and cs.cat_vets_id = cv.cat_vets_id
             and os.owner_vets_id = ov.owner_vets_id
             and ov.owner_id = o.owner_id
             and co.vet_id = ov.vet_id
             and co.vet_id = cv.vet_id
             and cos.last_visit >= sysdate - 4/24
        )
    where cs_is_alive = '1' 
    and (cos_is_current = '1' OR os_is_current='1')
    group by cat_name,cat_age,cat_weight,cs_is_alive,os_is_current,co_cat_owners_id,cos_is_current;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a taxonomy attached with my content type. While creating node of that
Attached is a quick program written under interview conditions that is designed to flatten
I attached an event handler to Entity Framework's SavingChanges event. Now, I found out
I attached a function to the REGEXP keyword in PHP and I discovered that
I'm trying to build a navigation window that never appears to end - each
I have a container div. Inside that container div are a number of smaller
Fiddle: http://jsfiddle.net/vuKqw/60/ What would allow the 'active' class to remain attached to an item
I have a ext series of functions attached to a onClick handler that appear
The attached screenshot is from OS X/Firefox 3. Note that the center tab (an
(see attached jsfiddle, screenshots; running browsers on Ubuntu 11.10) There seems to be some

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.