Answer the question
In order to leave comments, you need to log in
Php + MYSQL, when requested - loads the processor by 100%. How to be?
Installed PHP+MYSQL+LARAVEL (XAMMP).
query via LARAVEL
$list1 = DB::select( DB::raw(
"SELECT
pat.fam,
pat.otchestvo,
pat.name As namego,
pat.id,
spr.name,
spr_1.name As name2,
uslugi.dateout,
uslugi.stoim,
uslugi.skidka,
uslugi.summa,
uslugi.ids
FROM
uslugi INNER JOIN pat
ON uslugi.pat = pat.id
INNER JOIN spr
ON uslugi.proced = spr.ids
INNER JOIN spr spr_1
ON uslugi.usvrachi = spr_1. ids
WHERE spr.category = 'proced'
AND spr_1.category = 'vrachi'
AND spr.del = 0
AND spr_1.del = 0
AND uslugi.ok = 1
AND uslugi.vrach_talon = 1
AND uslugi.pat = :patid ORDER BY `uslugi`.`dateout` DESC"), array(
'patid' => $patid,
)) ;
REPLY 18 seconds
same request in phpmyadmin on the same server.
or from dbForge program
response 0.3 seconds.
What's the problem? I
try via PDO
echo " ".microtime(true);
$dbh = new PDO('mysql:host=localhost ;dbname=base1', 'admin', '1234');
echo "
".microtime(true);
foreach($dbh->query("SELECT
pat.fam,
pat.otchestvo,
pat.name As namego,
pat. id,
spr.name,
spr_1.name As name2,
uslugi.dateout,
uslugi.stoim,
uslugi.skidka,
uslugi.summa,
uslugi.ids
FROM
uslugi INNER JOIN pat
ON uslugi.pat = pat.id
INNER JOIN spr
ON uslugi.proced = spr.ids
INNER JOIN spr spr_1
ON uslugi.usvrachi = spr_1. ids
WHERE spr.category = 'proced'
AND spr_1.category = 'vrachi'
AND spr.del = 0
AND spr_1.del = 0
AND uslugi.ok = 1
AND uslugi.vrach_talon = 0
AND uslugi.pat = 60258 ORDER BY ` uslugi`.`dateout` DESC") as $row);
print_r($row);
echo "
".microtime(true);
1414614346.7337 - connected to base
1414614346.7337 loop
1414614366.7087 ended
366-346 = 20
Run from php console
C:\xampp\php>
C:\xampp\php>php C:\xampp\pub\test.php
1414618574.0765
1414618574.0785
1414618591.9187
97-74 = 23
All! Thank you! The issue was resolved by installing pure 64bit mysql on pure hardware with Win2008-64R2 serv.
1414625215.1427
1414625215.1567
1414625218.2285
Y - I will not look for it in the equation. no time.
Something strange with LAMP assemblies. (xammp) - maybe my specific version.
Answer the question
In order to leave comments, you need to log in
comment - Php windows vs linux. What causes differences on the same hardware?
topic - Php windows vs linux . What causes differences on the same hardware?
Perhaps the point is that phpmyadmin adds LIMIT to them when executing queries. How many rows are in the result? INNER JOIN gives a product of sets and in the absence of a limit, msql is forced to check all combinations, which is a lot even with indexes.
All! Thank you! The issue was resolved by installing pure 64bit mysql on pure hardware with Win2008-64R2 serv.
1414625215.1427
1414625215.1567
1414625218.2285
Y - I will not look for it in the equation. no time.
Something strange with LAMP assemblies. (xammp) - maybe my specific version.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question