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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:27:31+00:00 2026-05-20T03:27:31+00:00

select TABLE1.FIELD1, TABLE1.FIELD2, TABLE1.FIELD3, TABLE1.FIELD4, TABLE1.FIELD5, TABLE2.FIELD6, TABLE2.FIELD7 from TABLE1, TABLE2 where TABLE1.FIELD8 =

  • 0
select TABLE1.FIELD1, 
       TABLE1.FIELD2, 
       TABLE1.FIELD3, 
       TABLE1.FIELD4, 
       TABLE1.FIELD5, 
       TABLE2.FIELD6, 
       TABLE2.FIELD7
  from TABLE1,
       TABLE2
 where TABLE1.FIELD8 = 'value' 
   and TABLE2.FIELD6 = TABLE1.FIELD6;

I am searching for some data from 2 different tables.
(Oracle database – wherefields indexed for both tables)
The above query is taking 500ms to be executed.
When I search the tables seperately for the same fields
they finish in less than 20ms each.

I could search TABLE1 for the data I need (+FIELD6)
and then search TABLE2 for the rest using FIELD6.

My question is. Why is it so much slower when I join the tables.
Am I doing something wrong?

EDIT: Adding oracle’s explain plan

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------
| Id  | Operation                    |  Name                   | Rows  | Bytes | Cost  |
----------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |                         |  6318 |   586K|   620 |
|   1 |  HASH JOIN                   |                         |  6318 |   586K|   620 |
|   2 |   TABLE ACCESS BY INDEX ROWID| TABLE1                  |  6318 |   450K|     2 |
|   3 |    INDEX RANGE SCAN          | INDEX_TABLE1_FIELD8     |  2527 |       |     1 |
|   4 |   TABLE ACCESS FULL          | TABLE2                  |   430K|  9242K|   508 |
----------------------------------------------------------------------------------------

Note: cpu costing is off, 'PLAN_TABLE' is old version
  • 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-20T03:27:32+00:00Added an answer on May 20, 2026 at 3:27 am

    I can’t see anything wrong with your query, and the (good) advice given in other answers will help you understand what is going on in detail.

    In concept, however, you have to bear in mind the order of the data in each table, and whether the data is grouped up or spread out. It’s all well saying “it only takes 20ms to find”, but how long will it take to match the two data sets?

    If both data sets are Known to be in the same order, the RDBMS can align them relatively quickly. But the RDBMS can only know this from an index.

    If you have an index on Table1 that is Field8 then Field6, all the “values” will be lumped together, then ordered by Field6. If, however, you have an index of Field6 then Field8, the records you’re interested in will be ordered but spread out through the index. Finally, if you don’t have indexes on these fields, everything will be randomly ordered and spread out.

    Depending on these types of factor, there are literally dozens of ways the RDBMS may complete your query. For best performance, one needs to understand what the RDBMS would need to do, then give it the index(es) to make it as easy as possible.

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

Sidebar

Related Questions

No related questions found

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.