<p>Sounds like you're running into this: <a href="https://github.com/craftcms/cms/issues/4037" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/4037</a></p>
<p>Which is an issue in shared hosting environments where you're on a MySQL database server that contains a lot of other databases.</p>
<p>Some workarounds in that issue.</p>

CC BY-SA 4.0
2022-02-26T08:30:17.783Z
Thank you. Following that link, I just installed in a DigitalOcean droplet, and it is so snappy fast! Since I'm no expert on server security, if this were an important website, I'd probably use ArcusTech (have used them before), but I love the speed!
kr37
CC BY-SA 4.0
2022-02-25T17:44:49.520Z
2022-02-25T17:44:49.520Z
Brad Bell
<p>Occasionally when I've run into performance issues with MySQL for no discernible reason, I run the mysqlcheck optimize command to rebuild the tables and indexes, and it all just magically works again:</p>
<pre><code>mysqlcheck -u &lt;your mysql user&gt; -p&lt;your mysql password&gt; -o --all-databases
</code></pre>

CC BY-SA 4.0
2022-02-26T08:22:15.220Z
Thank you. It didn't seem to help in my case, but it seems like a good tool to have for the future!
kr37
CC BY-SA 4.0
2022-02-25T17:47:43.610Z
2022-02-25T17:47:43.610Z
Joe Forshaw
<p>On a new installation Craft CMS 3.7.34, with no sections and no plugins, it takes from 10 to 50 seconds to get the dashboard. And a similar time to get the default index page that says, &quot;Welcome. Thanks for installing Craft.&quot;</p>
<p>This is on shared hosting, and their tech support says it's a problem with the database, but they don't think it's their issue.</p>
<p>Looking at web.log, I see this query, which possibly is taking 19 seconds.</p>
<pre><code>2022-02-25 07:43:06 [-][1][-][profile end][yii\db\Command::query] SELECT `s`.`id`, `s`.`name`, `s`.`handle`, `s`.`language`, `s`.`primary`, `s`.`hasUrls`, `s`.`baseUrl`, `s`.`sortOrder`, `s`.`uid`, `s`.`dateCreated`, `s`.`dateUpdated`, `s`.`groupId`, `s`.`enabled`
FROM `sites` `s`
INNER JOIN `sitegroups` `sg` ON `sg`.`id` = `s`.`groupId`
WHERE (`s`.`dateDeleted` IS NULL) AND (`sg`.`dateDeleted` IS NULL)
ORDER BY `sg`.`name`, `s`.`sortOrder`
2022-02-25 07:43:25 [-][1][-][info][yii\web\Session::open] Session started
</code></pre>
<p>Following the advice from <a href="https://craftcms.com/knowledge-base/troubleshooting-performance-issues" rel="nofollow noreferrer">https://craftcms.com/knowledge-base/troubleshooting-performance-issues</a>, if I run that query in PHPMyAdmin, it takes .0006 seconds.</p>
<p>Any thoughts where to go from here?</p>
<h2>Their support says:</h2>
<p>It seems like the issue is related to your database. I started monitoring the website using x-ray tool then opened the website in browser and printed MySQL processes related to your account. The results are the following
According to the browser full load time is almost 29 seconds<br />
<a href="https://paste.websitehostserver.net/Z3Jvb3QK_2022-02-19_23-52-04_NXbZrpgHpT" rel="nofollow noreferrer">https://paste.websitehostserver.net/Z3Jvb3QK_2022-02-19_23-52-04_NXbZrpgHpT</a></p>
<p>As I mentioned above, I was manually checking MySQL processes from time to time, please take a look at the screenshot below<br />
<a href="https://paste.websitehostserver.net/text_2022-02-19_23-54-46_Mcn9EVmmdO" rel="nofollow noreferrer">https://paste.websitehostserver.net/text_2022-02-19_23-54-46_Mcn9EVmmdO</a></p>
<p>As you can see there were two queries that took, roughly speaking, 26 seconds. However, please note since I was checking them manually I might have missed something.</p>
<p>And here are the results of x-ray tool related to my attempt to check the website<br />
<a href="https://paste.websitehostserver.net/Z3Jvb3QK_2022-02-20_00-01-00_UdYX9cmDiC" rel="nofollow noreferrer">https://paste.websitehostserver.net/Z3Jvb3QK_2022-02-20_00-01-00_UdYX9cmDiC</a><br />
<a href="https://paste.websitehostserver.net/Z3Jvb3QK_2022-02-20_00-01-29_cf65oq0rLL" rel="nofollow noreferrer">https://paste.websitehostserver.net/Z3Jvb3QK_2022-02-20_00-01-29_cf65oq0rLL</a></p>
<hr />

<performance>
Slow DB on fresh install
# Slow DB on fresh install

(Asked by: username_0 on 2022-02-25)

On a new installation Craft CMS 3.7.34, with no sections and no plugins, it takes from 10 to 50 seconds to get the dashboard. And a similar time to get the default index page that says, "Welcome. Thanks for installing Craft."
This is on shared hosting, and their tech support says it's a problem with the database, but they don't think it's their issue.
Looking at web.log, I see this query, which possibly is taking 19 seconds.
2022-02-25 07:43:06 [-][1][-][profile end][yii\db\Command::query] SELECT `s`.`id`, `s`.`name`, `s`.`handle`, `s`.`language`, `s`.`primary`, `s`.`hasUrls`, `s`.`baseUrl`, `s`.`sortOrder`, `s`.`uid`, `s`.`dateCreated`, `s`.`dateUpdated`, `s`.`groupId`, `s`.`enabled`
FROM `sites` `s`
INNER JOIN `sitegroups` `sg` ON `sg`.`id` = `s`.`groupId`
WHERE (`s`.`dateDeleted` IS NULL) AND (`sg`.`dateDeleted` IS NULL)
ORDER BY `sg`.`name`, `s`.`sortOrder`
2022-02-25 07:43:25 [-][1][-][info][yii\web\Session::open] Session started

Following the advice from https://craftcms.com/knowledge-base/troubleshooting-performance-issues, if I run that query in PHPMyAdmin, it takes .0006 seconds.
Any thoughts where to go from here?
Their support says:
It seems like the issue is related to your database. I started monitoring the website using x-ray tool then opened the website in browser and printed MySQL processes related to your account. The results are the following
According to the browser full load time is almost 29 seconds
https://paste.websitehostserver.net/Z3Jvb3QK_2022-02-19_23-52-04_NXbZrpgHpT
As I mentioned above, I was manually checking MySQL processes from time to time, please take a look at the screenshot below
https://paste.websitehostserver.net/text_2022-02-19_23-54-46_Mcn9EVmmdO
As you can see there were two queries that took, roughly speaking, 26 seconds. However, please note since I was checking them manually I might have missed something.
And here are the results of x-ray tool related to my attempt to check the website
https://paste.websitehostserver.net/Z3Jvb3QK_2022-02-20_00-01-00_UdYX9cmDiC
https://paste.websitehostserver.net/Z3Jvb3QK_2022-02-20_00-01-29_cf65oq0rLL

**Tags:** performance

---

## 2 answers

### Answer by username_1 on 2022-02-25. Score: 2 | Accepted answer

Sounds like you're running into this: <https://github.com/craftcms/cms/issues/4037>

Which is an issue in shared hosting environments where you're on a MySQL database server that contains a lot of other databases.

Some workarounds in that issue.

> **Comments:**
> **username_0**: Thank you. Following that link, I just installed in a DigitalOcean droplet, and it is so snappy fast! Since I'm no expert on server security, if this were an important website, I'd probably use ArcusTech (have used them before), but I love the speed!  

---

### Answer by username_2 on 2022-02-25. Score: 2

Occasionally when I've run into performance issues with MySQL for no discernible reason, I run the mysqlcheck optimize command to rebuild the tables and indexes, and it all just magically works again:
mysqlcheck -u  -p -o --all-databases

> **Comments:**
> **username_0**: Thank you. It didn't seem to help in my case, but it seems like a good tool to have for the future!  

---

