mysql slow on first query, then fast for related queries

后端 未结 6 770
天涯浪人
天涯浪人 2020-12-29 07:12

I have been struggling with a problem that only happens when the database has been idle for a period of time for the data queried. The first query will be extremely slow, o

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 08:05

    MySQL Workbench:

    The below isn't 100% related to this SO question, but the symptoms are very related and this is the first SO result when searching for "mysql workbench slow" or related terms, so hopefully it's useful for others.

    Clear the query history! - following the process at MySql workbench query history ( last executed query / queries ) i.e. create / alter table, select, insert update queries to clear MySQL Workbench's query history really sped up the program for me.

    In summary: change the Output pane to History Output, right click on a Date and select Delete All Logs.

    The issue I was experiencing was "slow first query" in that it would take a few seconds to load the results even though the duration/fetch were well under 1 second. After clearing my query history, the duration/fetch times stayed the same (well under 1 second, so no DB behavior actually changed), but now the results loaded instantly rather than after a few second delay.

提交回复
热议问题