为什么datatable在live服务器中加载数据较慢?

wwwo4jvm  于 2021-06-15  发布在  Mysql
关注(0)|答案(0)|浏览(149)

我试图从一个包含3k条记录的表中加载数据。本地服务器的数据加载速度非常快,但当我将代码部署到服务器(实时网站)时,加载整个数据需要20-30秒。
服务器中的mysql版本: 5.7.24 php版本: 5.6.39-0+deb8u1 nginx/第1.6.2节
AJAX :

ajaxUrl: '<?php echo $this->MyHelper->Route('admin-get-blog-articles-faq')?>',
        columns: [
            my.common.admin.tableEditColumn('id'),
            { data: 'question' },
            { data: 'created_at' }
        ],

表格html:

<table id="records-table" class="table table-striped table-bordered" width="100%">
                                <thead>
                                    <tr>
                                        <th></th>
                                        <th class="hasinput">
                                            <input type="text" class="form-control filter" placeholder="Question">
                                        </th>
                                        <th class="hasinput">
                                            <input type="text" class="form-control filter" placeholder="Date Created">
                                        </th>
                                    </tr>
                                    <tr>
                                        <th></th>
                                        <th class="all">Question</th>
                                        <th class="all">Date Created</th>
                                    </tr>
                                </thead>
                                <tbody></tbody>
                            </table>

控制器功能代码:

public function getBlogArticlesFaqAction() {

        //Get all Blog Articles FAQ from DB
        $blogArticlesFaq = BlogArticleFaqModel::getAllForDataTable(array('id', 'question', 'created_at'));

        // Return data array
        return array('data' => $blogArticlesFaq);
    }

我使用的是mysql,我的表结构如下

id (PK auto increment), question, answer, created_at, updated_at

显示本地创建表:

CREATE TABLE `blog_article_faq` (
 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `question` text NOT NULL,
 `answer` text NOT NULL,
 `created_at` datetime DEFAULT NULL,
 `updated_at` datetime DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3735 DEFAULT CHARSET=utf8

直播节目创建:

CREATE TABLE `blog_article_faq` (
 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `question` text NOT NULL,
 `answer` text NOT NULL,
 `created_at` datetime DEFAULT NULL,
 `updated_at` datetime DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3735 DEFAULT CHARSET=utf8

更新:
在“网络”选项卡中,我注意到“大小”值增长非常缓慢,因此渲染可能需要时间!但是对于datatables,3k不是一个要渲染的大值,它可以很容易地渲染它,但是在我的例子中,这个size值增长非常慢!而且在当地增长很快。
网络选项卡捕捉

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题