<legend id='FNler'><style id='FNler'><dir id='FNler'><q id='FNler'></q></dir></style></legend>

    <small id='FNler'></small><noframes id='FNler'>

    <i id='FNler'><tr id='FNler'><dt id='FNler'><q id='FNler'><span id='FNler'><b id='FNler'><form id='FNler'><ins id='FNler'></ins><ul id='FNler'></ul><sub id='FNler'></sub></form><legend id='FNler'></legend><bdo id='FNler'><pre id='FNler'><center id='FNler'></center></pre></bdo></b><th id='FNler'></th></span></q></dt></tr></i><div id='FNler'><tfoot id='FNler'></tfoot><dl id='FNler'><fieldset id='FNler'></fieldset></dl></div>
      <bdo id='FNler'></bdo><ul id='FNler'></ul>
    1. <tfoot id='FNler'></tfoot>

    2. 使用 MySQL 的 PHP 很慢

      PHP with MySQL is slow(使用 MySQL 的 PHP 很慢)
    3. <legend id='dEicq'><style id='dEicq'><dir id='dEicq'><q id='dEicq'></q></dir></style></legend>

        <small id='dEicq'></small><noframes id='dEicq'>

        <i id='dEicq'><tr id='dEicq'><dt id='dEicq'><q id='dEicq'><span id='dEicq'><b id='dEicq'><form id='dEicq'><ins id='dEicq'></ins><ul id='dEicq'></ul><sub id='dEicq'></sub></form><legend id='dEicq'></legend><bdo id='dEicq'><pre id='dEicq'><center id='dEicq'></center></pre></bdo></b><th id='dEicq'></th></span></q></dt></tr></i><div id='dEicq'><tfoot id='dEicq'></tfoot><dl id='dEicq'><fieldset id='dEicq'></fieldset></dl></div>

          <tfoot id='dEicq'></tfoot>
                <bdo id='dEicq'></bdo><ul id='dEicq'></ul>

                  <tbody id='dEicq'></tbody>

                本文介绍了使用 MySQL 的 PHP 很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                (重要)编辑 3: 单独运行 testajax2.php 而 Ajax.持续时间大致相同,1.02-1.03 秒.所以我想这意味着问题出在 PHP-MySQL 或 XAMPP??

                (IMPORTANT) EDIT 3: Running the testajax2.php by itself and not Ajax. The duration is about the same, 1.02-1.03 seconds. So I guess that means the problem is in PHP-MySQL or XAMPP??

                当我通过 phpMyAdmin 查询运行它时,结果如下:显示行 0 -29(总共约 50 个.查询耗时 0.0015 秒).看来问题毕竟不在于 Ajax,而可能在于 PHP.我怎样才能解决这个问题?(我也刚刚编辑了问题标题.)

                When I ran it through a phpMyAdmin query, here's the result: Showing rows 0 - 29 ( ~50 total. The query took 0.0015 seconds). It appears the problem lies not in Ajax after all, but perhaps in PHP. How can I fix this? (I've also just edited the question title.)

                答案: 在位于 C:WindowsSystem32driversetc"的 hosts 文件中添加以下行

                   127.0.0.1 localhost
                


                之前的问题:

                jQuery Ajax 是否正常,另一端的 SQL 查询具有 1 秒的最短持续时间?我试过 $.get, $.post,$.getjson,$.ajax({type:'POST'})$.ajax({type:'GET'}).正如我所说,这是最低限度的.甚至可能会变得更糟到大约 3 秒.我怀疑这是 SQL 查询,因为当我在 phpMyAdmin 中尝试它们时,结果非常快.

                Is it normal for jQuery Ajax with SQL queries on the other side have the minimum duration of 1 second? I've tried $.get, $.post,$.getjson,$.ajax({type:'POST'}), $.ajax({type:'GET'}). As I've said, it's the minimum. It could get worse to about 3 seconds even. I doubt it's the SQL queries though, as when I try them in phpMyAdmin, the results come up extremely fast.

                如果查询非常简单并且表只有 2 个元素也没关系,它仍然会遵循 1 秒的最小值.我用的是最新的XAMPP,不知道有没有关系,但是我是通过localhost和127.0.0.1访问文件的.

                It doesn't matter also if the queries are very simple and the table only has 2 elements, it would still follow the 1 sec minimum. I'm using the latest XAMPP, and I don't know if it matters, but I'm accessing the files through localhost and 127.0.0.1.

                我在本地环境中运行它,在我制作这些文件的同一台笔记本电脑上.jQuery 已更新.返回的值/数组是 json_encoded.我正在使用 mysqli.数据库在InnoDB中,里面只有五张左右的表,几乎什么都没有他们.这是一个非常简单的示例查询:

                I'm running it on a local environment, on the same laptop I made these files on. jQuery is updated. The returned value/array is json_encoded. I'm using mysqli. The database is in InnoDB, and within are only about five tables, and there are hardly anything on them. Here's a very simple sample query:

                    var test_id =2;
                    testcall();
                    function testcall(){
                        $.ajax({
                            url: 'testajax2.php',
                            type: 'POST',
                            data: {test_id: test_id},
                            success: function(data){
                
                            }
                        });
                    }
                

                文件testajax2.php

                    $mysqli = new mysqli('localhost', 'root', '', 'testdb');
                    $mysqli->set_charset("utf8");
                    if(mysqli_connect_errno()) {
                        echo "Connection Failed: " . mysqli_connect_errno();
                        exit();
                    }
                
                    $testreceive = $_POST['test_id'];
                    $query = "SELECT First_Name from tblperson";
                    $result = $mysqli->query($query);
                    $row = $result->fetch_all(MYSQLI_ASSOC);
                
                    echo json_encode($row);
                

                tblperson 包含 50 条记录,并且只有四列.根据 Firebug 的说法,完成这个极其简单的任务需要 1.03 秒.我不确定它的真正含义,但通过 Net 选项卡查看nofollow noreferrer">Firebug,条形图完全是紫色的.0 和 1.03 秒等待.+1.03 秒和 0 接收.

                The tblperson contains 50 records, and there are only four columns. According to Firebug, it took 1.03 seconds to do that extremely simple task. I'm not sure what it really means, but viewing through the Net tab in Firebug, the bar is entirely violet. 0 and 1.03 seconds Waiting. +1.03 seconds and 0 receiving.

                如果我将它们发送为 json_encode($row)foreach($row as $value){ echo $value['First_Name'];}.它仍然至少需要 1 秒.我在 Chrome 和 Safari 上尝试过,虽然我无法确定确切的持续时间,但我可以说它大致相同.但是对于一个简单的 Ajax 调用,没有 SQL 查询.如果我没记错的话,速度非常快.我会带着样本和持续时间输出回来.

                It also doesn't matter if I send them as json_encode($row) or foreach($row as $value){ echo $value['First_Name']; }. It would still be about at least 1 second. I've tried on Chrome and Safari, and though I can't have the exact duration, I can tell that it's about the same. But for a simple Ajax call with no SQL queries. If I remember correctly, it's very fast. I'd be back with a sample and duration output.

                推荐答案

                在位于"C:WindowsSystem32driversetc"的hosts文件中添加以下行

                   127.0.0.1 localhost
                

                这解决了我的问题.PHP-MySQL 现在可以完成其任务,具体取决于 20-500 ms 之间的复杂程度.

                This solved my problem. PHP-MySQL can now complete its task depending on how complex somewhere between 20-500 ms.

                这篇关于使用 MySQL 的 PHP 很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
              • <legend id='O93Or'><style id='O93Or'><dir id='O93Or'><q id='O93Or'></q></dir></style></legend>
                  <tbody id='O93Or'></tbody>

                <small id='O93Or'></small><noframes id='O93Or'>

                          <bdo id='O93Or'></bdo><ul id='O93Or'></ul>
                          <tfoot id='O93Or'></tfoot>

                          <i id='O93Or'><tr id='O93Or'><dt id='O93Or'><q id='O93Or'><span id='O93Or'><b id='O93Or'><form id='O93Or'><ins id='O93Or'></ins><ul id='O93Or'></ul><sub id='O93Or'></sub></form><legend id='O93Or'></legend><bdo id='O93Or'><pre id='O93Or'><center id='O93Or'></center></pre></bdo></b><th id='O93Or'></th></span></q></dt></tr></i><div id='O93Or'><tfoot id='O93Or'></tfoot><dl id='O93Or'><fieldset id='O93Or'></fieldset></dl></div>