0
I am trying to improve the performance of my pages to improve the user experience, but, I am not able to identify the problem.
According to Google, it is recommended that the pages respond in less than 0.4 seconds, however, only the connection to the database, this taking 0.41 seconds. Whether by mysql_connect or mysqli_connect
Also, the same query I run to mount a menu, in PHP it takes on average 0.14 but in phpMyAdmin it only takes 0.0009 as shown in execution
Showing records from 0 - 24 (total 35, Query took 0.0009 sec)
I created an empty page, only with connection and query to measure times
http://omenorpreco.com/teste.php
Anyone have any idea how can I decrease the time to make the connection, and, decrease the query time to turn into Phpmyadmin?
UPDATE:
//PHP
$sql = "select cd_categoria, linha, slug, cd_categoria_site, qtd from ( SELECT cd_categoria, if (menu.cd_categoria_pai=0,menu.nm_categoria,concat((select nm_categoria from tb_st_category where cd_categoria = menu.cd_categoria_pai),';',nm_categoria)) as linha , if (menu.cd_categoria_pai=0,menu.nm_slug,concat((select nm_slug from tb_st_category where cd_categoria = menu.cd_categoria_pai),'/',menu.nm_slug)) as slug , cd_categoria as cd_categoria_site , 0 as qtd FROM tb_st_category menu where cd_categoria_pai = 0 ) as a order by linha";
$pagespeed = microtime_float();
$query = $mysqli->query($sql);
echo "Query Time:".number_format(microtime_float()-$pagespeed, 2, ',', '')."<br>";
Is this query or is this different from php? Show how you did your test php code. However I think you’re confusing.
– Guilherme Nascimento
I updated the post with the PHP data (I just did not put the code of the connection with the database, but it is mysqli (I have tried with mysql as well)
– Rodrigo Mendes