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

  • Home
  • SEARCH
  • 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 8793743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:09:43+00:00 2026-06-13T23:09:43+00:00

There are DDL statements: CREATE TABLE t1( c1 INT NOT NULL ); CREATE TABLE

  • 0

There are DDL statements:

CREATE TABLE t1(
c1 INT NOT NULL
);
CREATE TABLE t2(
c2 INT NOT NULL
);

My query:

SELECT c1 FROM t1 WHERE c1 NOT IN (SELECT c2 from t2)

EXPLAIN output:

id  select_type table   type    possible_keys   key key_len ref rows    Extra
1   PRIMARY t1  ALL NULL    NULL    NULL    NULL    3   Using where
2   DEPENDENT SUBQUERY  t2  ALL NULL    NULL    NULL    NULL    3   Using where

Subquery doesn’t correlate with outer query. Why it’s type is DEPENDENT SUBQUERY?

UPD: query is SELECT c1 FROM t1 WHERE c1 NOT IN (SELECT c2 from t2)

  • 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-06-13T23:09:44+00:00Added an answer on June 13, 2026 at 11:09 pm

    The execution planner / optimizer of the MySQL version you are using, rewrites the query internally as a correlated subquery (or to be more accurate, both these are transformed into the same execution plan):

    SELECT c1 
    FROM t1 
    WHERE NOT EXISTS 
          (SELECT * from t2 WHERE c2 = t1.c1) ;
    

    This type of query is called antijoin (or anti-semijoin) and can also be written in another way, with a LEFT JOIN / WHERE IS NULL, which produces in MySQL (5.1 and 5.5 versions) a slightly different Explain plan:

    SELECT t1.c1 
    FROM t1 
      LEFT JOIN t2 ON t2.c2 = t1.c1
    WHERE t2.c2 IS NULL ;
    

    Notice that in other versions, like the 5.6 (which is still in development), or in MariaDB (that has some optimizer improvements in the recent versions), the queries may be rewritten differently.

    Even in the same version, the final execution plan for the same query (and especially for more complex ones) may vary from execution to execution, depending on the indexes available, the sizes of the tables and several other factors.

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

Sidebar

Related Questions

Is there any easy way to retrieve table creation DDL from Microsoft Access (2007)
there's a table and some ddl in updatepanel. like this: why this happens???
I have a tool that generates a DDL script create table ATTRIBUTE_VALUE ( id
I can view C# code from .NET ddl's with ILSpy. Are there any programs
Does anyone know of a reasonably priced tool that will create DDL statements to
There is a column that exists in 2 tables. In table 1, this column
There is a directed graph having a single designated node called root from which
There are two intents on the receiver side which are called from the same
There are two table s : one is the master and one the detail
There is any way to set the generic type (T) of class in the

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.