MySQL Single Left Join Very SlowMySQL very slow query when changing one WHERE field despite no index/keyHelp...

Class Action - which options I have?

Unreliable Magic - Is it worth it?

Is exact Kanji stroke length important?

How does Loki do this?

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

India just shot down a satellite from the ground. At what altitude range is the resulting debris field?

How can a function with a hole (removable discontinuity) equal a function with no hole?

when is out of tune ok?

You cannot touch me, but I can touch you, who am I?

How can I kill an app using Terminal?

Why escape if the_content isnt?

Term for the "extreme-extension" version of a straw man fallacy?

How did Doctor Strange see the winning outcome in Avengers: Infinity War?

Is there a good way to store credentials outside of a password manager?

Fastening aluminum fascia to wooden subfascia

Two monoidal structures and copowering

Is this apparent Class Action settlement a spam message?

What does "I’d sit this one out, Cap," imply or mean in the context?

How does it work when somebody invests in my business?

Large drywall patch supports

What happens if you roll doubles 3 times then land on "Go to jail?"

How do I go from 300 unfinished/half written blog posts, to published posts?

Is `x >> pure y` equivalent to `liftM (const y) x`

Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?



MySQL Single Left Join Very Slow


MySQL very slow query when changing one WHERE field despite no index/keyHelp optimizing MySQL slow queryOptimizing multi-table left joinsBaffled with MySQL LEFT JOIN query that I have to speed it upWhy does IN (subquery) perform bad when = (subquery) is blazing fast?Deciding which MySQL execution plan is betterVery Simple MySQL Inner Join Extremely SlowSlow SELECT examining whole tableselect MAX() from MySQL view (2x INNER JOIN) is slowMySQL not using primary key on inner join













0















SELECT
DISTINCT contacts.id FROM contacts FORCE INDEX (PRIMARY)
LEFT JOIN
emails_stats ON contacts.id = emails_stats.contact_id
WHERE
contacts.client_code = 121212121212
GROUP BY
contacts.id;


Table contacts:



Rows: ~74k; Indexes: primary and client_code



Table emails_stats



Rows: ~20k; Indexes: primary and contact_id



The query explain:



1   SIMPLE  contacts        index   PRIMARY,client_code PRIMARY 108 NULL    73258   Using where
1 SIMPLE emails_stats index NULL contact_id 36 NULL 19382 Using where; Using index








share







New contributor




Kafer76 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    SELECT
    DISTINCT contacts.id FROM contacts FORCE INDEX (PRIMARY)
    LEFT JOIN
    emails_stats ON contacts.id = emails_stats.contact_id
    WHERE
    contacts.client_code = 121212121212
    GROUP BY
    contacts.id;


    Table contacts:



    Rows: ~74k; Indexes: primary and client_code



    Table emails_stats



    Rows: ~20k; Indexes: primary and contact_id



    The query explain:



    1   SIMPLE  contacts        index   PRIMARY,client_code PRIMARY 108 NULL    73258   Using where
    1 SIMPLE emails_stats index NULL contact_id 36 NULL 19382 Using where; Using index








    share







    New contributor




    Kafer76 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      SELECT
      DISTINCT contacts.id FROM contacts FORCE INDEX (PRIMARY)
      LEFT JOIN
      emails_stats ON contacts.id = emails_stats.contact_id
      WHERE
      contacts.client_code = 121212121212
      GROUP BY
      contacts.id;


      Table contacts:



      Rows: ~74k; Indexes: primary and client_code



      Table emails_stats



      Rows: ~20k; Indexes: primary and contact_id



      The query explain:



      1   SIMPLE  contacts        index   PRIMARY,client_code PRIMARY 108 NULL    73258   Using where
      1 SIMPLE emails_stats index NULL contact_id 36 NULL 19382 Using where; Using index








      share







      New contributor




      Kafer76 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      SELECT
      DISTINCT contacts.id FROM contacts FORCE INDEX (PRIMARY)
      LEFT JOIN
      emails_stats ON contacts.id = emails_stats.contact_id
      WHERE
      contacts.client_code = 121212121212
      GROUP BY
      contacts.id;


      Table contacts:



      Rows: ~74k; Indexes: primary and client_code



      Table emails_stats



      Rows: ~20k; Indexes: primary and contact_id



      The query explain:



      1   SIMPLE  contacts        index   PRIMARY,client_code PRIMARY 108 NULL    73258   Using where
      1 SIMPLE emails_stats index NULL contact_id 36 NULL 19382 Using where; Using index






      mysql





      share







      New contributor




      Kafer76 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Kafer76 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Kafer76 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 3 mins ago









      Kafer76Kafer76

      1




      1




      New contributor




      Kafer76 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Kafer76 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Kafer76 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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
          });


          }
          });






          Kafer76 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f233308%2fmysql-single-left-join-very-slow%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








          Kafer76 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Kafer76 is a new contributor. Be nice, and check out our Code of Conduct.













          Kafer76 is a new contributor. Be nice, and check out our Code of Conduct.












          Kafer76 is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • 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%2fdba.stackexchange.com%2fquestions%2f233308%2fmysql-single-left-join-very-slow%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

          Parapolítica Índice Antecedentes El escándalo Proceso judicial Consecuencias Véase...

          How to remove border from elements in the last row?Targeting flex items on the last rowHow to vertically wrap...

          Tecnologías entrañables Índice Antecedentes Desarrollo Tecnologías Entrañables en la...