Error Code: 2013. Lost connection to MySQL server during query 30.002 sec












0















There are a lot of issues with the same topic as mine but my content and issue seems to be different. In my workbench, i run the code



`select(msgid) from `table`.log where 
id = 'example' and status = 'active' and month(created_at) = 12
and year(created_at) = 2018 limit 0,10;`


The above code works fine but when i run the code b



`select(msgid), count(msgid) from `table`.log where 
id = 'example' and status = 'active' and month(created_at) = 12
and year(created_at) = 2018 limit 0,10;`


i get the error




>
Error Code: 2013. Lost connection to MySQL server during query 30.002 sec




Why could this be happening in my workbench ?



PS: New to workbench and mysql










share|improve this question


















  • 2





    Why is your query so slow? You might want to focus on making it faster instead.

    – Salman A
    Jan 2 at 18:14
















0















There are a lot of issues with the same topic as mine but my content and issue seems to be different. In my workbench, i run the code



`select(msgid) from `table`.log where 
id = 'example' and status = 'active' and month(created_at) = 12
and year(created_at) = 2018 limit 0,10;`


The above code works fine but when i run the code b



`select(msgid), count(msgid) from `table`.log where 
id = 'example' and status = 'active' and month(created_at) = 12
and year(created_at) = 2018 limit 0,10;`


i get the error




>
Error Code: 2013. Lost connection to MySQL server during query 30.002 sec




Why could this be happening in my workbench ?



PS: New to workbench and mysql










share|improve this question


















  • 2





    Why is your query so slow? You might want to focus on making it faster instead.

    – Salman A
    Jan 2 at 18:14














0












0








0








There are a lot of issues with the same topic as mine but my content and issue seems to be different. In my workbench, i run the code



`select(msgid) from `table`.log where 
id = 'example' and status = 'active' and month(created_at) = 12
and year(created_at) = 2018 limit 0,10;`


The above code works fine but when i run the code b



`select(msgid), count(msgid) from `table`.log where 
id = 'example' and status = 'active' and month(created_at) = 12
and year(created_at) = 2018 limit 0,10;`


i get the error




>
Error Code: 2013. Lost connection to MySQL server during query 30.002 sec




Why could this be happening in my workbench ?



PS: New to workbench and mysql










share|improve this question














There are a lot of issues with the same topic as mine but my content and issue seems to be different. In my workbench, i run the code



`select(msgid) from `table`.log where 
id = 'example' and status = 'active' and month(created_at) = 12
and year(created_at) = 2018 limit 0,10;`


The above code works fine but when i run the code b



`select(msgid), count(msgid) from `table`.log where 
id = 'example' and status = 'active' and month(created_at) = 12
and year(created_at) = 2018 limit 0,10;`


i get the error




>
Error Code: 2013. Lost connection to MySQL server during query 30.002 sec




Why could this be happening in my workbench ?



PS: New to workbench and mysql







php mysql mysql-workbench






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 2 at 18:02









CodeNewbieCodeNewbie

216




216








  • 2





    Why is your query so slow? You might want to focus on making it faster instead.

    – Salman A
    Jan 2 at 18:14














  • 2





    Why is your query so slow? You might want to focus on making it faster instead.

    – Salman A
    Jan 2 at 18:14








2




2





Why is your query so slow? You might want to focus on making it faster instead.

– Salman A
Jan 2 at 18:14





Why is your query so slow? You might want to focus on making it faster instead.

– Salman A
Jan 2 at 18:14












3 Answers
3






active

oldest

votes


















0














You should try to increase DBMS connection read time out .



Go to Workbench Edit → Preferences → SQL Editor → DBMS connections read time out : increase this to 6000






share|improve this answer
























  • there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

    – CodeNewbie
    Jan 2 at 18:10











  • can you send upload a screenshot of the menu you are getting. also what's inside 'sql execution'

    – Sourabh Swarnkar
    Jan 2 at 18:13





















0














You can change timeout from :



Edit → Preferences → SQL Editor → DBMS connection read time out (in seconds): 600



Changed it to a greater value than your current.



**UPDATE
you can set read timeout also by:



SET @@local.net_read_timeout=360;





share|improve this answer


























  • there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

    – CodeNewbie
    Jan 2 at 18:10











  • What version of workbench you have? check it and comment here, and you can execute query to do that check my updated answer

    – Tarreq
    Jan 2 at 18:11





















0














Here's a screenshot of the preferences from MySQL Workbench 8.0.13. I've put arrows indicating where you should select "SQL Editor" and then where you find the "DBMS connection read timeout interval" field.



enter image description here



I agree with the comment from @SalmanA, you should optimize your query so it's not so slow.



In particular, you should use indexes to help the query narrow down the rows to report. But you can't do that when you use functions like month(created_at) and year(created_at). Presuming you have an index on created_at, you need to put that column by itself on the left side of comparison operators:



... AND created_at >= '2018-12-01' AND created_at < '2019-01-01'


The best index for this query would be a compound index:



ALTER TABLE log ADD INDEX (id, status, created_at, msg_id);





share|improve this answer


























    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%2f54011056%2ferror-code-2013-lost-connection-to-mysql-server-during-query-30-002-sec%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You should try to increase DBMS connection read time out .



    Go to Workbench Edit → Preferences → SQL Editor → DBMS connections read time out : increase this to 6000






    share|improve this answer
























    • there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

      – CodeNewbie
      Jan 2 at 18:10











    • can you send upload a screenshot of the menu you are getting. also what's inside 'sql execution'

      – Sourabh Swarnkar
      Jan 2 at 18:13


















    0














    You should try to increase DBMS connection read time out .



    Go to Workbench Edit → Preferences → SQL Editor → DBMS connections read time out : increase this to 6000






    share|improve this answer
























    • there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

      – CodeNewbie
      Jan 2 at 18:10











    • can you send upload a screenshot of the menu you are getting. also what's inside 'sql execution'

      – Sourabh Swarnkar
      Jan 2 at 18:13
















    0












    0








    0







    You should try to increase DBMS connection read time out .



    Go to Workbench Edit → Preferences → SQL Editor → DBMS connections read time out : increase this to 6000






    share|improve this answer













    You should try to increase DBMS connection read time out .



    Go to Workbench Edit → Preferences → SQL Editor → DBMS connections read time out : increase this to 6000







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 2 at 18:05









    Sourabh SwarnkarSourabh Swarnkar

    58113




    58113













    • there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

      – CodeNewbie
      Jan 2 at 18:10











    • can you send upload a screenshot of the menu you are getting. also what's inside 'sql execution'

      – Sourabh Swarnkar
      Jan 2 at 18:13





















    • there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

      – CodeNewbie
      Jan 2 at 18:10











    • can you send upload a screenshot of the menu you are getting. also what's inside 'sql execution'

      – Sourabh Swarnkar
      Jan 2 at 18:13



















    there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

    – CodeNewbie
    Jan 2 at 18:10





    there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

    – CodeNewbie
    Jan 2 at 18:10













    can you send upload a screenshot of the menu you are getting. also what's inside 'sql execution'

    – Sourabh Swarnkar
    Jan 2 at 18:13







    can you send upload a screenshot of the menu you are getting. also what's inside 'sql execution'

    – Sourabh Swarnkar
    Jan 2 at 18:13















    0














    You can change timeout from :



    Edit → Preferences → SQL Editor → DBMS connection read time out (in seconds): 600



    Changed it to a greater value than your current.



    **UPDATE
    you can set read timeout also by:



    SET @@local.net_read_timeout=360;





    share|improve this answer


























    • there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

      – CodeNewbie
      Jan 2 at 18:10











    • What version of workbench you have? check it and comment here, and you can execute query to do that check my updated answer

      – Tarreq
      Jan 2 at 18:11


















    0














    You can change timeout from :



    Edit → Preferences → SQL Editor → DBMS connection read time out (in seconds): 600



    Changed it to a greater value than your current.



    **UPDATE
    you can set read timeout also by:



    SET @@local.net_read_timeout=360;





    share|improve this answer


























    • there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

      – CodeNewbie
      Jan 2 at 18:10











    • What version of workbench you have? check it and comment here, and you can execute query to do that check my updated answer

      – Tarreq
      Jan 2 at 18:11
















    0












    0








    0







    You can change timeout from :



    Edit → Preferences → SQL Editor → DBMS connection read time out (in seconds): 600



    Changed it to a greater value than your current.



    **UPDATE
    you can set read timeout also by:



    SET @@local.net_read_timeout=360;





    share|improve this answer















    You can change timeout from :



    Edit → Preferences → SQL Editor → DBMS connection read time out (in seconds): 600



    Changed it to a greater value than your current.



    **UPDATE
    you can set read timeout also by:



    SET @@local.net_read_timeout=360;






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 2 at 18:14

























    answered Jan 2 at 18:07









    TarreqTarreq

    603312




    603312













    • there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

      – CodeNewbie
      Jan 2 at 18:10











    • What version of workbench you have? check it and comment here, and you can execute query to do that check my updated answer

      – Tarreq
      Jan 2 at 18:11





















    • there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

      – CodeNewbie
      Jan 2 at 18:10











    • What version of workbench you have? check it and comment here, and you can execute query to do that check my updated answer

      – Tarreq
      Jan 2 at 18:11



















    there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

    – CodeNewbie
    Jan 2 at 18:10





    there is no DBMS connection read time out (in seconds) for mine..all i have is query editor , object editor , 'sql execution'

    – CodeNewbie
    Jan 2 at 18:10













    What version of workbench you have? check it and comment here, and you can execute query to do that check my updated answer

    – Tarreq
    Jan 2 at 18:11







    What version of workbench you have? check it and comment here, and you can execute query to do that check my updated answer

    – Tarreq
    Jan 2 at 18:11













    0














    Here's a screenshot of the preferences from MySQL Workbench 8.0.13. I've put arrows indicating where you should select "SQL Editor" and then where you find the "DBMS connection read timeout interval" field.



    enter image description here



    I agree with the comment from @SalmanA, you should optimize your query so it's not so slow.



    In particular, you should use indexes to help the query narrow down the rows to report. But you can't do that when you use functions like month(created_at) and year(created_at). Presuming you have an index on created_at, you need to put that column by itself on the left side of comparison operators:



    ... AND created_at >= '2018-12-01' AND created_at < '2019-01-01'


    The best index for this query would be a compound index:



    ALTER TABLE log ADD INDEX (id, status, created_at, msg_id);





    share|improve this answer






























      0














      Here's a screenshot of the preferences from MySQL Workbench 8.0.13. I've put arrows indicating where you should select "SQL Editor" and then where you find the "DBMS connection read timeout interval" field.



      enter image description here



      I agree with the comment from @SalmanA, you should optimize your query so it's not so slow.



      In particular, you should use indexes to help the query narrow down the rows to report. But you can't do that when you use functions like month(created_at) and year(created_at). Presuming you have an index on created_at, you need to put that column by itself on the left side of comparison operators:



      ... AND created_at >= '2018-12-01' AND created_at < '2019-01-01'


      The best index for this query would be a compound index:



      ALTER TABLE log ADD INDEX (id, status, created_at, msg_id);





      share|improve this answer




























        0












        0








        0







        Here's a screenshot of the preferences from MySQL Workbench 8.0.13. I've put arrows indicating where you should select "SQL Editor" and then where you find the "DBMS connection read timeout interval" field.



        enter image description here



        I agree with the comment from @SalmanA, you should optimize your query so it's not so slow.



        In particular, you should use indexes to help the query narrow down the rows to report. But you can't do that when you use functions like month(created_at) and year(created_at). Presuming you have an index on created_at, you need to put that column by itself on the left side of comparison operators:



        ... AND created_at >= '2018-12-01' AND created_at < '2019-01-01'


        The best index for this query would be a compound index:



        ALTER TABLE log ADD INDEX (id, status, created_at, msg_id);





        share|improve this answer















        Here's a screenshot of the preferences from MySQL Workbench 8.0.13. I've put arrows indicating where you should select "SQL Editor" and then where you find the "DBMS connection read timeout interval" field.



        enter image description here



        I agree with the comment from @SalmanA, you should optimize your query so it's not so slow.



        In particular, you should use indexes to help the query narrow down the rows to report. But you can't do that when you use functions like month(created_at) and year(created_at). Presuming you have an index on created_at, you need to put that column by itself on the left side of comparison operators:



        ... AND created_at >= '2018-12-01' AND created_at < '2019-01-01'


        The best index for this query would be a compound index:



        ALTER TABLE log ADD INDEX (id, status, created_at, msg_id);






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 2 at 18:21

























        answered Jan 2 at 18:15









        Bill KarwinBill Karwin

        384k64520678




        384k64520678






























            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%2f54011056%2ferror-code-2013-lost-connection-to-mysql-server-during-query-30-002-sec%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

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith