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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:49:01+00:00 2026-05-31T01:49:01+00:00

Query 1: select distinct email from mybigtable where account_id=345 takes 0.1s Query 2: Select

  • 0

Query 1:

select distinct email from mybigtable where account_id=345

takes 0.1s

Query 2:

Select count(*) as total from mybigtable where account_id=123 and email IN (<include all from above result>)

takes 0.2s

Query 3:

Select count(*) as total from mybigtable where account_id=123 and email IN (select distinct email from mybigtable where account_id=345)

takes 22 minutes and 90% its in the “preparing” state. Why does this take so much time.

Table is innodb with 3.2mil rows on MySQL 5.0

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

    After much deliberation and with help from dba.se, this is the final query that worked majic.

    select count(*) EmailCount from
    (
        select tbl123.email from
        (select email from mybigtable where account_id=123) tbl123
        LEFT JOIN
        (select distinct email from mybigtable where account_id=345) tbl345
        using (email)
        WHERE tbl345.email IS NULL
    ) A;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query: SELECT DISTINCT w.name, count(*) FROM widgets AS w JOIN
Let say that we have the following query: SELECT DISTINCT COUNT(`users_id`) FROM `users_table`; this
I am executing a following query: SELECT DISTINCT users.user_id, users.email, users.irc_nickname FROM users, user_group_map,
Query: SELECT DISTINCT ([Equipment List].ID) AS Expr1, [Job Assignments].Job FROM [Equipment List] LEFT JOIN
I am using this query: SELECT DISTINCT pat.PublicationID FROM dbo.PubAdvTransData AS pat INNER JOIN
The following query: SELECT DISTINCT ClassName FROM SiteTree ORDER BY ClassName is returning things
I have this query: SELECT DISTINCT IM.EDIFICIOS_ID, TI.TITULAR FROM IMPORTACION IM INNER JOIN I_EDIFICIO
I make a query: String query = SELECT DISTINCT a FROM A a FETCH
I need help with a query to get distinct records from the table. SELECT
Here is my query: SELECT dbo.EmailCampaignTracking.emailOpened, dbo.EmailCampaignTracking.emailUnsubscribed, dbo.EmailCampaignTracking.emailBounced, COUNT(*) FROM dbo.EmailCampaignTracking Group By dbo.EmailCampaignTracking.emailBounced,

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.