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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:19:11+00:00 2026-05-19T01:19:11+00:00

Am mainly looking at improving the performance of the query and also whether be

  • 0

Am mainly looking at improving the performance of the query and also whether be able to solve in a single query for one of my use case explained below:

There are 2 tables involved:

Table 1: EMPLOYEE (column1, column2, email1, email2, column5, column6)
Table 2: EMAILLIST (email)

My requirement is, I want to get/fetch all records from the table EMPLOYEE with the condition that either email1 or email2 do not have a matching entry in EMAILLIST table. To put it simply, if either email1 or email2 matches in EMAILLIST table, then those records should be ignored.

In this case, EMPLOYEE.EMAIL1, EMPLOYEE.EMAIL2 and EMAILLIST.EMAIL will always have single email address stored.

We’re using PostgreSQL v8.2.3, if it matters.

Any pointers/ideas/logic are appreciated.

UPDATE: Currently, we’ve implemented in this way: Fetched all records from EMPLOYEE table and stored in a Java object and for each entry (for loop), this in turn checks in EMAILLIST table, which is costly in terms of performance.

  • 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-19T01:19:12+00:00Added an answer on May 19, 2026 at 1:19 am

    The most efficient way to handle this for every rdbms I’ve dealt with is to handle it with outer joins:

    SELECT whatever
    FROM employee AS e
    LEFT JOIN emaillist AS em1 ON e.email1 = em1.email
    LEFT JOIN emaillist AS em2 ON e.email2 = em2.email
    WHERE em1.id IS NULL
        AND em2.id IS NULL
    

    In general, I think you’ll find that any case where you put database queries into a loop will be, ummm, suboptimal. 🙂

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

Sidebar

Related Questions

I'm looking to write a tool that aims to convert debug symbols of one
I guess this question was asked in one way or another, but I'm looking
I'm looking to implement source control for my team. An external requirement that came
I'am looking for an eclipse-plugin for doxygen code documentation. I have found the eclox-plugIn
I am looking into creating a new website using ASP.NET 4.0. I am currently
I'm interested in doing rapid app development in Python. Since this is mainly for
I have an application that receives a pointer to JPEG data from a camera
I have worked with java for a while now, and I found checkstyle to
I have the following HttpModule that I wanted to unit test. Problem is I
I've been writing a Web Application recently that interacts with iPhones. The iPhone iphone

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.