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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:56:59+00:00 2026-05-26T02:56:59+00:00

I have two tables with the following columns: Table1 { ID NUMBER(15), ROLL_NUM VARCHAR2(9),

  • 0

I have two tables with the following columns:

Table1
{   ID            NUMBER(15),
    ROLL_NUM      VARCHAR2(9),
    BATCH_NUM     VARCHAR2(6),
    ACCT_BALANCE  NUMBER(15,2)
}

Table2
{   Table1_ID      NUMBER(15) REFERENCES TABLE1.ID,
    SEQ_NUM       NUMBER(2),
    TRANS_NUM     VARCHAR2(10),
    TRANS_AMT     NUMBER(8,2),
    TRANS_DT      DATE
}

Table1 has 200,000 records and Table2 has 500,000 records

I have simple joins as follows:

SQL #1:

SELECT A.ROLL_NUM, A.ACCT_BALANCE, B.TRANS_NUM, TRANS_AMT, TRANS_DT
FROM   TABLE1 A, TABLE2 B
WHERE  B.Table1_ID = A.ID
AND    A.BATCH_NUM = 400012

SQL #2:

SELECT A.ROLL_NUM, A.ACCT_BALANCE, B.TRANS_NUM, TRANS_AMT, TRANS_DT
FROM   TABLE1 A, TABLE2 B
WHERE  B.Table1_ID = A.ID
AND    A.BATCH_NUM = '400012'

SQL #3:

SELECT A.ROLL_NUM, A.ACCT_BALANCE, B.TRANS_NUM, TRANS_AMT, TRANS_DT
FROM   TABLE1 A, TABLE2 B
WHERE  B.Table1_ID = A.ID
AND    A.BATCH_NUM = TO_NUMBER('400012')

The expected result from the count should be 500,000 if every BATCH_NUM from Table1 is ‘400012’ and all the ID’s match up in Table2.

When I run these queries in Oracle (v11 or v10), SQL #2 seems to take forever and I had to stop the query from running after 10 to 15 minutes. SQL #1 and #3 seems to come back with results instantaneously with the full 500,000 records in less than a second. At first, I thought it was an indexing issue, but adding the index doesn’t do anything to resolve the issue. I tried this query in TOAD and in SQL Developer with the same results.

I’m at a loss here because the BATCH_NUM column in Table1 is a VARCHAR2 and you’d think that an implicit conversion of the data types would cause the query to be slower, not faster than a non-converted comparison. Can someone explain this?

  • 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-26T02:56:59+00:00Added an answer on May 26, 2026 at 2:56 am

    I agree that use of implicit conversion would prevent an index access path.

    To be sure what’s really going on, do the following:

    explain plan for
    select ......
    /
    

    Then, immediately following that, do:

    select * from table(dbms_xplan.display);
    

    and post the results.

    Without looking at the execution plan, anything I say would be guesswork.

    Oh, and please post the definitions of all indexes that exist on the tables.

    -Mark

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

Sidebar

Related Questions

I have two tables that have following rows: Table1 ID Name Number ===================== 1
I have two tables: User , table1 and table2 . User has_many table1 .
I've two tables which have following columns: Now I want have a SQL query
I have two tables with the following (simplified) structures: table "Factors" which holds data
I am using VB.NET with LINQ to MS SQL. I have two following tables.
I have two tables t1 and t2 as following t1 A B C D
I have two database tables with the following structure: actions: action_id int(11) primary key
I have two tables that I am joining with the following query... select *
I have two tables as shown in the following diagram : as you saw
I have two tables invoices and pending_payments both of which have the following rows

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.