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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:54:44+00:00 2026-05-26T05:54:44+00:00

I have two tables, TableA and TableB. TableA is a large dataset with thousands/millions

  • 0

I have two tables, TableA and TableB.

TableA is a large dataset with thousands/millions of record and has a unique key (ID) and 3 alternate keys (NAME,SCHOOL,DATE).
Table B is a smaller dataset with thousands of record and has no unique keys.

TableA
---------
ID
NAME
SCHOOL
DATE
RECORD
STATUS
TableB
---------
NAME
SCHOOL

Now, I need to join these two tables to get the list of unique IDs to be use in another query. Below is the sample query, but this took so long more hours to run.

SELECT a.ID AS ID_key, a.school, a.name
   FROM TableA a, TableB b
 WHERE a.name = b.name
  AND a.school = b.school
  AND a.status = 'Active' 

Is there any way to optimize this query? Thanks in advance.

  • 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-26T05:54:45+00:00Added an answer on May 26, 2026 at 5:54 am

    Why are you joining the tables at all if all the information required is in table A?

    The only possible reason I can think of is if you want to exclude rows in A that don’t have a corresponding row in B but, if your schema is set up properly, you would probably have a foreign key constraint to enforce that.

    If that’s not the case, get rid of the join altogether:

    SELECT a.ID AS ID_key,
           a.school,
           a.name
    FROM   TableA
    WHERE  status = 'Active' 
    

    If there is a valid reason for the join (and, from your comment, that seems to be the case), make sure that you have indexes on name and school in both tables, and that your runstats (or whatever Oracle calls its query optimisation data) are up to date.

    Also run a query analysis (explain) on that query to find out where the problem lies. Once you have that as a baseline, you can begin modifying things (like adding indexes) to see if the query improves. Remember the #1 mantra for optimisation: measure, don’t guess!

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

Sidebar

Related Questions

Scenario: Let's say I have two tables, TableA and TableB. TableB's primary key is
I have two tables, related by a common key. So TableA has key AID
Say for example, I have the following two tables: TableA { _id } TableB
I have two tables: p_group.full_data, which is a large dataset I'm working on (100k
I have two large tables: products -------- id (char) (primary key) somefield1 (char) somefield2
I have a large table (~1M rows now, soon ~10M) that has two ranked
i have two mysql tables tableA colA1 colA2 1 whatever 2 whatever 3 whatever
i have two msaccess tables tableA textA numA bd 1 as 0 aa 2
I have two tables: table1, table2. Table1 has 10 columns, table2 has 2 columns.
Suppose I have two tables: Group ( id integer primary key, someData1 text, someData2

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.