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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:43:56+00:00 2026-05-27T11:43:56+00:00

I have a processing in database that iterate over an entire table. At some

  • 0

I have a processing in database that iterate over an entire table. At some point, I need to check if a VARCHAR matches any value in a column.

I want to know what is the fast way to do this. Do SQL comparison each time? Retrieve the table values to a VARCHAR array? Another solution?

The iteration in the table is over millions, so the comparison will be done million times. In the match table, there a few hundred values.

So, what is the best approach for 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-27T11:43:56+00:00Added an answer on May 27, 2026 at 11:43 am

    Have an index on the varchar column in the small table. Then the look-up will be as fast as possible. A plain btree index (default) is good for the equality operator.

    CREATE INDEX smalltbl_lookup ON smalltbl(lookup);
    

    If you only look up some values, this will be the fastest way:

    EXISTS (SELECT * FROM smalltbl WHERE lookup = bigtbl.lookup)
    

    Resulting in an index search. If you look up all values (does not sound like you do), a LEFT JOIN is faster:

    SELECT *
    FROM bigtbl b
    LEFT JOIN smalltbl s USING (lookup)
    

    Transforming the values from the small table into array and checking there cannot compete with an index search.

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

Sidebar

Related Questions

I need to write an app that that will iterate over our database, and
I have a simple work role in azure that does some data processing on
I have 20 factory machines all processing tasks. I have a database adapter that
I have a action.php which does some processing involving a MySQL-Database. In action.php I
I have a table in the database that I'm retrieving using LINQ to SQL,
I have a simple mySQL database table that I am loading into a PHP
I have a table in a central database that gets constantly appended to. I
In a legacy project that I'm on, we have several processing that are preformed
I have to do some processing on a file loaded by the user. This
I have a database that is filled with information for films, which is (in

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.