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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:49:35+00:00 2026-05-15T04:49:35+00:00

I have a table T1 with 60 rows and 5 columns: ID1, ID2, info1,

  • 0

I have a table T1 with 60 rows and 5 columns: ID1, ID2, info1, info2, info3.

I have a table T2 with 1.2 million rows and another 5 columns: ID3, ID2, info4, info5, info6.

I want to get (ID1, ID2, info4, info5, info6) from all the rows where the ID2s match up. Currently my query looks like this:

SELECT T1.ID1, T2.ID2,
       T2.info4, T2.info5, T2.info6
  FROM T1, T2
 WHERE T1.ID2 = T2.ID2;

This takes about 15 seconds to run. My question is – should it take that long, and if not, how can I speed it up? I figure it shouldn’t since T1 is so small.

I asked PostgreSQL to EXPLAIN the query, and it says that it hashes T2, then hash joins that hash with T1. It seems hashing T2 is what takes so long. Is there any way to write the query so it doesn’t have to hash T2? Or, is there a way to have it cache the hash of T2 so it doesn’t re-do it? The tables will only be updated every few days.

If it makes a difference, T1 is a temporary table created earlier in the session.

  • 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-15T04:49:36+00:00Added an answer on May 15, 2026 at 4:49 am

    It should not take that long 🙂

    Creating an index on T2( ID2 ) should improve the performance of your query:

    CREATE INDEX idx_t2_id2 ON t2 (id2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a large table (450 million rows containing 34 columns of numeric or
I have 2 tables. Table Accs contains 9 million rows (3 columns: acc_id, month,
I have a table with arbitrary columns and rows. This fact is irrelevant though
I have two columns in my table and the rows are created dynamically. <table
I have a simple HTML Table (10 columns x 500 rows). When the page
I have a very simple table with two columns, but has 4.5M rows. CREATE
I have 1 million rows in MySql table temp and wish to multiply column
I have a table with multiple rows and columns populated by php and mySQL.
I have a table with two rows with four columns. I have text in
I have got a table with several rows and columns. I have a span

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.