Mysql 8.0 not exists vs not in vs left join vs where count(*)INNER JOIN ON vs WHERE clauseHow to 'insert if not exists' in MySQL?What's the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN?MySQL INNER JOIN of 3 tables with count and totalsMySQL Limit LEFT JOIN Subquery after joiningjdbc - Unable to store russian chinese arabic letters in mysqlJOIN Query In MYSQL and PHPMYSQL Error Installing BuildEnginesql import error, invalid default valuehow to optimize a select query with multiple left joins in a large database

Bob has never been a M before

What will be the benefits of Brexit?

Reply ‘no position’ while the job posting is still there (‘HiWi’ position in Germany)

How to prevent YouTube from showing already watched videos?

Is there an Impartial Brexit Deal comparison site?

Is there a problem with hiding "forgot password" until it's needed?

Can somebody explain Brexit in a few child-proof sentences?

Books on the History of math research at European universities

Perfect riffle shuffles

Simple image editor tool to draw a simple box/rectangle in an existing image

Would it be legal for a US State to ban exports of a natural resource?

Can the harmonic series explain the origin of the major scale?

Calculating the number of days between 2 dates in Excel

Can a controlled ghast be a leader of a pack of ghouls?

Should my PhD thesis be submitted under my legal name?

Is there any significance to the Valyrian Stone vault door of Qarth?

A Standard Integral Equation

Why does this part of the Space Shuttle launch pad seem to be floating in air?

How can I successfully establish a nationwide combat training program for a large country?

Resetting two CD4017 counters simultaneously, only one resets

Invariance of results when scaling explanatory variables in logistic regression, is there a proof?

Female=gender counterpart?

Freedom of speech and where it applies

A car is moving at 40 km/h. A fly at 100 km/h, starts from wall towards the car(20 km away)flies to car and back. How many trips can it make?



Mysql 8.0 not exists vs not in vs left join vs where count(*)


INNER JOIN ON vs WHERE clauseHow to 'insert if not exists' in MySQL?What's the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN?MySQL INNER JOIN of 3 tables with count and totalsMySQL Limit LEFT JOIN Subquery after joiningjdbc - Unable to store russian chinese arabic letters in mysqlJOIN Query In MYSQL and PHPMYSQL Error Installing BuildEnginesql import error, invalid default valuehow to optimize a select query with multiple left joins in a large database













-2















Mysql 8.0 not exists vs not in vs left join vs where count(*)



i don't know why not in is fast



A ############
SELECT
a.openid
FROM
user_all a
WHERE
a.openid NOT IN ( SELECT b.openid FROM `user` b );


B ###############



SELECT
a.openid
FROM
user_all AS a
WHERE
( SELECT COUNT( * ) AS num FROM `user` AS b WHERE a.openid = b.openid ) = 0


C ###########



SELECT
a.openid
FROM
user_all a
LEFT JOIN `user` b ON a.openid = b.openid
WHERE
b.openid IS NULL;


D #########



SELECT
a.openid
FROM
user_all a
WHERE
NOT EXISTS ( SELECT * FROM `user` b WHERE a.openid = b.openid );


################



this is my table message



CREATE TABLE `user_all` (
`openid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_german2_ci;


CREATE TABLE `user` (
`openid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_german2_ci;


user_all table size 921W
user table size 373W


Explain results:



this is explain result for use <code>not in</code>this is explain result for use <code>left join</code>this is explain result for use <code>NOT EXISTS</code>this is explain result for use <code>where count()</code>










share|improve this question
























  • What is the question?

    – Thomas G
    Mar 8 at 7:57











  • I don't know why not in is faster than not exists.

    – Eric_余浩
    Mar 8 at 8:02











  • People say that not in and in are slow, but I find that not in is the fastest of the four SQLs mentioned above.

    – Eric_余浩
    Mar 8 at 8:04











  • That's not a question

    – Strawberry
    Mar 8 at 8:04






  • 2





    For such a question you should show the explain plan of all queries and your table's structure with indexes. How can we deduct from what you posted, the performance of each query? We cant.

    – Thomas G
    Mar 8 at 8:04















-2















Mysql 8.0 not exists vs not in vs left join vs where count(*)



i don't know why not in is fast



A ############
SELECT
a.openid
FROM
user_all a
WHERE
a.openid NOT IN ( SELECT b.openid FROM `user` b );


B ###############



SELECT
a.openid
FROM
user_all AS a
WHERE
( SELECT COUNT( * ) AS num FROM `user` AS b WHERE a.openid = b.openid ) = 0


C ###########



SELECT
a.openid
FROM
user_all a
LEFT JOIN `user` b ON a.openid = b.openid
WHERE
b.openid IS NULL;


D #########



SELECT
a.openid
FROM
user_all a
WHERE
NOT EXISTS ( SELECT * FROM `user` b WHERE a.openid = b.openid );


################



this is my table message



CREATE TABLE `user_all` (
`openid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_german2_ci;


CREATE TABLE `user` (
`openid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_german2_ci;


user_all table size 921W
user table size 373W


Explain results:



this is explain result for use <code>not in</code>this is explain result for use <code>left join</code>this is explain result for use <code>NOT EXISTS</code>this is explain result for use <code>where count()</code>










share|improve this question
























  • What is the question?

    – Thomas G
    Mar 8 at 7:57











  • I don't know why not in is faster than not exists.

    – Eric_余浩
    Mar 8 at 8:02











  • People say that not in and in are slow, but I find that not in is the fastest of the four SQLs mentioned above.

    – Eric_余浩
    Mar 8 at 8:04











  • That's not a question

    – Strawberry
    Mar 8 at 8:04






  • 2





    For such a question you should show the explain plan of all queries and your table's structure with indexes. How can we deduct from what you posted, the performance of each query? We cant.

    – Thomas G
    Mar 8 at 8:04













-2












-2








-2


1






Mysql 8.0 not exists vs not in vs left join vs where count(*)



i don't know why not in is fast



A ############
SELECT
a.openid
FROM
user_all a
WHERE
a.openid NOT IN ( SELECT b.openid FROM `user` b );


B ###############



SELECT
a.openid
FROM
user_all AS a
WHERE
( SELECT COUNT( * ) AS num FROM `user` AS b WHERE a.openid = b.openid ) = 0


C ###########



SELECT
a.openid
FROM
user_all a
LEFT JOIN `user` b ON a.openid = b.openid
WHERE
b.openid IS NULL;


D #########



SELECT
a.openid
FROM
user_all a
WHERE
NOT EXISTS ( SELECT * FROM `user` b WHERE a.openid = b.openid );


################



this is my table message



CREATE TABLE `user_all` (
`openid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_german2_ci;


CREATE TABLE `user` (
`openid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_german2_ci;


user_all table size 921W
user table size 373W


Explain results:



this is explain result for use <code>not in</code>this is explain result for use <code>left join</code>this is explain result for use <code>NOT EXISTS</code>this is explain result for use <code>where count()</code>










share|improve this question
















Mysql 8.0 not exists vs not in vs left join vs where count(*)



i don't know why not in is fast



A ############
SELECT
a.openid
FROM
user_all a
WHERE
a.openid NOT IN ( SELECT b.openid FROM `user` b );


B ###############



SELECT
a.openid
FROM
user_all AS a
WHERE
( SELECT COUNT( * ) AS num FROM `user` AS b WHERE a.openid = b.openid ) = 0


C ###########



SELECT
a.openid
FROM
user_all a
LEFT JOIN `user` b ON a.openid = b.openid
WHERE
b.openid IS NULL;


D #########



SELECT
a.openid
FROM
user_all a
WHERE
NOT EXISTS ( SELECT * FROM `user` b WHERE a.openid = b.openid );


################



this is my table message



CREATE TABLE `user_all` (
`openid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_german2_ci;


CREATE TABLE `user` (
`openid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_german2_ci;


user_all table size 921W
user table size 373W


Explain results:



this is explain result for use <code>not in</code>this is explain result for use <code>left join</code>this is explain result for use <code>NOT EXISTS</code>this is explain result for use <code>where count()</code>







mysql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 10:06









LukStorms

14.1k31734




14.1k31734










asked Mar 8 at 7:52









Eric_余浩Eric_余浩

62




62












  • What is the question?

    – Thomas G
    Mar 8 at 7:57











  • I don't know why not in is faster than not exists.

    – Eric_余浩
    Mar 8 at 8:02











  • People say that not in and in are slow, but I find that not in is the fastest of the four SQLs mentioned above.

    – Eric_余浩
    Mar 8 at 8:04











  • That's not a question

    – Strawberry
    Mar 8 at 8:04






  • 2





    For such a question you should show the explain plan of all queries and your table's structure with indexes. How can we deduct from what you posted, the performance of each query? We cant.

    – Thomas G
    Mar 8 at 8:04

















  • What is the question?

    – Thomas G
    Mar 8 at 7:57











  • I don't know why not in is faster than not exists.

    – Eric_余浩
    Mar 8 at 8:02











  • People say that not in and in are slow, but I find that not in is the fastest of the four SQLs mentioned above.

    – Eric_余浩
    Mar 8 at 8:04











  • That's not a question

    – Strawberry
    Mar 8 at 8:04






  • 2





    For such a question you should show the explain plan of all queries and your table's structure with indexes. How can we deduct from what you posted, the performance of each query? We cant.

    – Thomas G
    Mar 8 at 8:04
















What is the question?

– Thomas G
Mar 8 at 7:57





What is the question?

– Thomas G
Mar 8 at 7:57













I don't know why not in is faster than not exists.

– Eric_余浩
Mar 8 at 8:02





I don't know why not in is faster than not exists.

– Eric_余浩
Mar 8 at 8:02













People say that not in and in are slow, but I find that not in is the fastest of the four SQLs mentioned above.

– Eric_余浩
Mar 8 at 8:04





People say that not in and in are slow, but I find that not in is the fastest of the four SQLs mentioned above.

– Eric_余浩
Mar 8 at 8:04













That's not a question

– Strawberry
Mar 8 at 8:04





That's not a question

– Strawberry
Mar 8 at 8:04




2




2





For such a question you should show the explain plan of all queries and your table's structure with indexes. How can we deduct from what you posted, the performance of each query? We cant.

– Thomas G
Mar 8 at 8:04





For such a question you should show the explain plan of all queries and your table's structure with indexes. How can we deduct from what you posted, the performance of each query? We cant.

– Thomas G
Mar 8 at 8:04












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058863%2fmysql-8-0-not-exists-vs-not-in-vs-left-join-vs-where-count%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058863%2fmysql-8-0-not-exists-vs-not-in-vs-left-join-vs-where-count%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229