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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:21:35+00:00 2026-05-26T01:21:35+00:00

I have the following MySql table containing my raw event data (about 1.5 million

  • 0

I have the following MySql table containing my raw event data (about 1.5 million rows)

userId  | pathId  | other stuff....

I have an index on userId, pathId (approx 50,000 unique combinations)

During my processing, I identify 30,000 userId, pathId values that I don’t want, but I do want to keep the original raw table. So I want to copy all rows into a processed event table, except the rows that match this 30,000 userId, pathId values.

An approach I’m considering is to write the 30,000 userId,PathId values of the rows I do not want into a temp_table, and then doing something like this:

[create table processed_table ...]
insert into processed_table 
   select * from raw_table r 
   where not exists (
       select * from temp_table t where r.userId=t.userid and r.pathId=t.pathId
   )

For info, processed_table generally ends up being half the size of raw_table.

Anyway, this seems to work but my SQL skills are limited, so my question (finally) is – is this the most efficient way to do 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-26T01:21:35+00:00Added an answer on May 26, 2026 at 1:21 am

    No, it’s not the most efficient. Source

    That’s why the best way to search for missing values in MySQL is using a LEFT JOIN / IS NULL or NOT IN rather than NOT EXISTS.

    Here’s an example with NOT IN:

    INSERT INTO processed_table 
    SELECT *
    FROM raw_table 
    WHERE (userId, pathId) NOT IN (
        SELECT userId, pathId FROM temp_table
    )
    

    And LEFT JOIN ... IS NULL:

    INSERT INTO processed_table 
    SELECT *
    FROM raw_table r
    LEFT JOIN temp_table t
    ON r.userId = t.userid AND r.pathId = t.pathId
    WHERE t.userId IS NULL
    

    However, since your table is very small and has only 50,000 rows, your original query is probably fast enough.

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

Sidebar

Related Questions

I have a MySQL table containing event data. On this table, I have a
I have a MySQL table with the following data (simplified): INSERT INTO `stores` (`storeId`,
I have the following mysql table called test. lets say it has the data
I have a MySQL table containing userID , score . A single user can
So, I have got following data in a MySQL table: mysql> SELECT * FROM
So im having a problem (obviously). I have the following MySQL table data 7
I have a MySQL database containing the following tables: Table: Professor Attributes: ID, ProfessorName
I have the following Mysql Table Order table status 0 - incomplete status 1
I have the following MySQL table structure: num field company phone website 1 Gas
I have a following mysql table with a lot (3000+) of values: [id] [parent_id]

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.