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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:26:47+00:00 2026-06-16T15:26:47+00:00

Is it faster to programmatically join tables or use SQL Join statements when one

  • 0

Is it faster to programmatically join tables or use SQL Join statements when one table is much smaller?

More specifically, how does grabbing a string from a hashmap<int, string> of the smaller table and setting its value to the objects returned from the larger table compare to pre-joining the tables on the database? Does the relative sizes of the two tables make a difference?

Update: To rephrase my question. Does grabbing the subset of the larger table (the 5,000 – 20,000 records I care about) and then programmatically joining the smaller table (which I would cache locally) out perform an SQL join? Does the SQL join apply to the whole table or just the subset of the larger table that would be returned?

SQL Join Statement:

SELECT id, description
FROM values v, descriptions d
WHERE v.descID=d.descID
AND v.something = thingICareAbout;

Individual Statements:

SELECT id, descID
FROM values
WHERE v.something = thingICareAbout;

SELECT descID, description
FROM descriptions d;

Programmatic join:

for (value : values){
    value.setDescription(descriptions.get(value.getDescID))
}

Additional Info: There are a total of 800,000,000 records in the larger table that corresponding to 3,000 values in the smaller table. Most searches return between 5,000 – 20,000 results. This is an oracle DB.

  • 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-06-16T15:26:48+00:00Added an answer on June 16, 2026 at 3:26 pm

    In general, joining tables like this is the sort of operation that SQL databases are optimized for, so there is a good chance that they’re fairly hard to beat on this sort of operation.

    The relative size of the two tables might make a difference if you attempt to do the join “manually” as you have to factor in the additional memory consumption to hold the bigger table data in memory while you’re doing your processing.

    While this example is pretty easy to get right, by doing the join yourself you also lose a built-in data integrity check that the database would give you if you let it do the join.

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

Sidebar

Related Questions

Is it faster to do multiple SQL finds on one table with different conditions
which one is faster select * from parents p inner join children c on
Which one is more faster between DataTable and SqlDataReader while I'm trying to fill
Which is faster for millions of records: Permanent Table or Temp Tables? I have
Does the page load faster if i use the javascript before the </body> tag?
We have a SQL server database. To manipulate the data non-programmatically, I can use
Is it better / faster inside an event listener to use this or event.target
Which one is faster? Which one uses less memory? Console.WriteLine(string1) Console.WriteLine(string2) Console.WriteLine(string3) Console.WriteLine(stringNth) or
What is faster in SQL Server 2005/2008, a Stored Procedure or a View? EDIT:
Are JOIN queries faster than several queries? (You run your main query, and then

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.