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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:01:22+00:00 2026-05-14T00:01:22+00:00

I have a very simple query that’s giving me unexpected results. Hints on where

  • 0

I have a very simple query that’s giving me unexpected results. Hints on where to troubleshoot it would be welcome.

Simplified, the query is:

SELECT Obs.obsDate, 
       Obs.obsValue, 
       ObsHead.name
  FROM ml.Obs Obs 
  JOIN ml.ObsHead ObsHead ON ObsHead.hdId = Obs.hdId
 WHERE obs.hdId IN (53, 54)

This gives me a query cost of: 963. However, if I change the query to:

SELECT Obs.obsDate, 
       Obs.obsValue, 
       ObsHead.name
  FROM ml.Obs Obs 
  JOIN ml.ObsHead ObsHead ON ObsHead.hdId = Obs.hdId
 WHERE ObsHead.name IN ('BP SYSTOLIC', 'BP DIASTOLIC')

Although it (should) return the same data, the estimated cost shoots up to 17688. Where is the problem here likely to lie? Thanks.

Edit: The query plan says that the index on ObsHead.Name is being used for a range scan, and the table access on ObsHead only costs 4. There’s another index on Obs.hdId that’s being used for a range scan costing 94: it’s the Nested Loops join between the tables that jumps up to 17K.

  • 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-14T00:01:22+00:00Added an answer on May 14, 2026 at 12:01 am

    As has already been stated, the plan’s cost is not intended for comparing two different queries, only for comparing different paths for the same query.

    This is only a guess, but in this case, the cardinality field of the plan might be more useful to you. If the index on OBSHEAD is not unique and the statistics were gathered using an estimate, then the optimizer may not know exactly how many rows to expect when querying that table. The cardinality will tell you whether this is true or not (ideally, you’ll be seeing a cardinality of 2 for OBSHEAD).

    Another suggestion is to check the statistics on OBS. It seems likely that is a table that grows frequently, in which case, January 28th is not recent enough to have gathered the statistics. Assuming monitoring is turned on for this table, the queries below can tell you if the statistics are stale and need to be refreshed.

    select owner, table_name, last_analyzed, stale_stats
    from all_tab_statistics
    where owner = 'ML' and table_name = 'OBS';
    
    select owner, index_name, last_analyzed, stale_stats
    from all_ind_statistics
    where owner = 'ML' and table_name = 'OBS';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple query that is not much more complicated than: select
I have a very simple query $this->db->select('id, title'); $this->db->order_by('id', 'DESC'); $query = $this->db->get('journal'); foreach($query->result()
I have very simple query that calls a UDF which splits a field by
I have a very simple query that only returns one record. When I try
I have very simple query like this: SELECT * FROM `all_conversations` WHERE `deleted_1` !=
This is a very simple complexive query that I have. I need the solution.
I have a very simple query: select * from tbl1 where title not in('asdasd',
I have a very simple query that is driving me absolutely nuts. Here's the
I have a very simple question. I have an SQL query that looks like
I have a simple query that spits out new_users by day... Select trunc(create_dtime),Count(Player_Id) as

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.