Answer the question
In order to leave comments, you need to log in
Why is the same serial query running slower?
Good afternoon everyone,
On one project (without CMS) I noticed that the same action (for example, deleting a post with an ajax request) is slower every time.
That is, on the page I clicked "delete" - an ajax request went, returned after 80ms. I scroll down - I press delete - the post request has already returned after 3s and so on ... The next one will return after 8 seconds
I have no idea where to dig? Maybe the host has something?
Answer the question
In order to leave comments, you need to log in
Is the response from the request to the browser returned with a delay or in a JS callback? If in the browser, then first of all, log everything related to this request on the server (execution time in the database, processing time, etc.). It will become clear in which direction to dig.
Where is it slowing down? Have you looked at the network tab in chrome's developer tools?
Well, you need to profile the code, you can use xdebug, or you can just stick $time_start = microtime(true); <кусок кода> $time_end = microtime(true) - $time_start;
it in and see how long each piece was running.
Ps bad code: WHERE id = ".$_POST['id']." - sql injection
It's strange,
this request is slowly executed from the second time (the further, the slower)
$res = mysql_query("INSERT INTO
b_lists_users_ids
SET user_vk_id = ".$_POST['user_vk_id']."
, bl_acc_to_app = '1'
, not_srch_posts_vk = '1'
, reason = '".mysql_real_escape_string($_POST['reason'])."'
, user_vk_id_add = '".$_SESSION['vk_id']."'
, date_add = UNIX_TIMESTAMP()
, user_vk_id_edit = '".$_SESSION['vk_id']."'
, date_edit = UNIX_TIMESTAMP()
ON DUPLICATE KEY UPDATE
is_active = '1'
, bl_acc_to_app = '1'
, not_srch_posts_vk = '1'
, reason = '".mysql_real_escape_string($_POST['reason'])."'
, user_vk_id_edit = '".$_SESSION['vk_id']."'
, date_edit = UNIX_TIMESTAMP()
");
At random: try to copy the data from the session and close it at the beginning of the script.
<?php
session_start();
$sessionData = $_SESSION;
session_close();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question