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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:48:27+00:00 2026-05-30T21:48:27+00:00

Query: select max(b.counter) as counter, b.m_group, b.m_code, a.s_id, s.id_sk from tbl_various a, tbl_map b,

  • 0

Query:

select max(b.counter) as counter,
       b.m_group,
       b.m_code,
       a.s_id,
       s.id_sk
  from tbl_various a, tbl_map b, tbl_sheet s
 where coalesce(b.part, a.part) = a.part
   and coalesce(b.nums, to_number(a.nums)) = a.nums
   and coalesce(b.interc, a.interc) = a.interc
   and coalesce(b.segment, a.segment) = a.segment
   and coalesce(b.acountry, a.acountry) = a.acountry_midas
   and coalesce(b.orig_name, a.orig_name) = a.orig_name
   and coalesce(b.fact, a.fact) = a.fact
   and b.sect is not null
   and s.m_code = b.m_code
 group by b.m_group, b.m_code, a.s_id, s.id_sk;

Plan:

SELECT STATEMENT, GOAL = ALL_ROWS       86763   1           169
 HASH GROUP BY                          86763   1           169
  HASH JOIN                             86762   1           169
   TABLE ACCESS FULL    TBL_MAP         2       1717        92718
   MERGE JOIN CARTESIAN                 79688   300133251   34515323865
    TABLE ACCESS FULL   TBL_SHEET       5       912         18240
    BUFFER SORT                         79682   329274      31281030
     TABLE ACCESS FULL  TBL_VARIOUS     87      329274      31281030

Group by is too slow… How does it speed up?

  • 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-05-30T21:48:29+00:00Added an answer on May 30, 2026 at 9:48 pm

    Any row in b that has null values in all the coalesce’d columns and is not null in b.sect and b.m_code will match any row in a, ie do a cartesian join.

    My guess is that this is causing the problem. Even if there actually are no such rows in b, the optimizer may go for the cartesian join.

    You may be able to avoid this by adding

    and (b.part is not null or b.nums is not null or b.intersec is not null or etc... )
    

    Also, its always a good idea to keep your statistics up-to-date (though I’m not enough of an Oracle expert to know how to do that).


    EDIT: This is functionally identical and might work better:

    and (b.part = a.part or b.nums = a.nums or b.intersec = a.intersec or etc... )
    

    This will make sure that at least one value matches.

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

Sidebar

Related Questions

Why query: SELECT id, MAX(probe_time) AS Expr1 FROM app_states GROUP BY logon_id and SELECT
Using the following query: SELECT pe.prodtree_element_name_l, MAX(rs.resource_value) AS resource_value FROM prodtree_element pe LEFT JOIN
When I execute this query: Dim Var Var = ("select max(Autonumber) from tblAutonumber") DoCmd.RunSQL
I want to write a query like this: SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order
I have a query that looks a bit like this: SELECT weekEnd, MAX(timeMonday) FROM
I have the following query: SELECT MAX([LastModifiedTime]) FROM Workflow There are approximately 400M rows
For the query: SELECT MAX(LOG_CREATION_DATE),COL_A, COL_B FROM IMPORT_LOG GROUP BY TO_CHAR(LOG_CREATION_DATE, 'MM-DD-YYYY'), COL_A, COL_B
I have the following query: SELECT * from foo where timestamp = (select max(timestamp)
I have this query SELECT products_list.id_cat_unique, products_categories_list.*, COUNT(products_list.id_cat_unique) as counter FROM products_categories_ids LEFT JOIN
Ok, this is my query: SELECT video_category, video_url, video_date, video_title, short_description, MAX(video_id) FROM videos

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.