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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:00:37+00:00 2026-05-13T06:00:37+00:00

in mysql i have two tables tableA col1 col2 SIM1 ……….col24 ———————————– a x

  • 0

in mysql i have two tables

tableA

col1   col2  SIM1 ..........col24
-----------------------------------
a       x     1             5 
b       y     1             3
c       z     0             2
d       g     2             1

tableB

colA   colB   SIM2
-------------------
x       g     1
y       f     0
x       s     0
y       e     2

Actually the number of records in the two tables in 0.4 million

i have a java program from which i am executing sql query using jdbc.

here is the query

     SELECT * 
      FROM TableA 
INNER JOIN TableB ON TableA.SIM1 =  TableB.SIM2 
INTO OUTFILE 'c:/test12226.csv' "+ 
FIELDS TERMINATED BY ',' 
ENCLOSED BY '\"'  
LINES TERMINATED BY '\n' 

This query is taking a really long time. for my application to be feasible this should not take more than 30 seconds. i understand the records are 0.4 million but such an operation in ms access takes less than 10 seconds. is java-mysql combination more time consuming than ms-access

i have allocated 1GB ram in debug configuration. please suggest.

  • 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-13T06:00:37+00:00Added an answer on May 13, 2026 at 6:00 am

    My guess is that one or both of TableA.SIM1 and TableB.SIM2 aren’t indexed. Either that or they’re different data types (eg VARCHAR and NUMERIC). Try:

    CREATE INDEX index_name1 ON TableA (SIM1);
    CREATE INDEX index_name2 ON TableB (SIM2);
    

    Without indexes that query will be really slow. One table will be accessed record by record, which is fine since you’re outputting the whole table. To find the corresponding record in the other table it needs to look up based on the SIM1 = SIM2 relationship.

    To find records in the other table without an index it has to look through every record. This is a linear or O(n) lookup. Put half a million records in each table and that’s an awful lot of comparisons required to find all the matches (billions in facts).

    With the indexes the record matching is near-instant.

    Think of it this way: indexing the columns is like putting a telephone book in alphabetical order. That makes it easy to find surnames. If the telephone book wasn’t sorted at all how long would it take you to find someone’s phone number?

    Now multiply that by half a million.

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

Sidebar

Related Questions

I have two mysql tables, one containing details on cars and one containing all
When I have two mysql servers that have different jobs (holding different databases) but
Say I have an MSSQL table with two columns: an int ID column that's
I have two issues both related to (I believe) my SQL Server setup. I
I am fairly new to MySQL and have a project in which I need
I'm writng a small application in PHP + MySQL and have come to the
Anyone knows how to get sum of number? For example i have mysql column
I have a MySQL query that returns a result with a single column of
I have a MySQL table with approximately 3000 rows per user. One of the
I have a MySQL database behind a firewall which can only be accessed via

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.