首页 > 解决方案 > 非常慢的交互与大量数据负载

问题描述

我用节点开发了我的应用程序,该节点在页面上应该加载 3800 条或更多记录并将其显示在表格上。我设法创建了一些过滤器,当我应用它们时,页面需要一段时间才能响应。我创建的过滤器只是客户端,他们唯一要做的就是隐藏过滤器之外的表格元素。

这是我的服务器端代码:

app.get('/query', (req,res) =>{
        sql='SELECT u.sendingdate, cl.alias, u.customerkey, cl.idCliente, u.media, cl.nomeCliente, i.Nazione, u.itemkey, u.publicationname, u.publicationkey FROM uploads AS u LEFT JOIN customer AS cl ON cl.idCliente = u.idCliente LEFT JOIN rubric AS r ON r.idRubric = u.customerkey LEFT JOIN  tab_iso AS i ON u.countryisocode = i.ISO WHERE u.sendingdate >= "' + start + '" AND u.sendingdate <= "' + end + '"  GROUP BY c.id;'
        con.query(sql, (err, uploads, fields) =>{
            if (err) throw err;
            con.query('SELECT i.Nations FROM uploads AS u LEFT JOIN tab_iso AS i ON u.countryisocode = i.ISO GROUP BY Nations;', (err, nations, fields) =>{
                if (err) throw err;
                res.render('query.ejs', {uploads: uploads, nations: nations})
                //SELECT ... FROM ... WHERE somecol >= '2011-01-01' AND somecol <= '2011-01-30'
            })
        })
    })

这是页面,我使用ejs:

<table id="table" cellspacing="0" class="ui sortable celled table display" style="width:100%">
                    <thead>
                        <tr>
                            <th class="">Item Key</th>
                            <th class="">Date</th>
                            <th class="">Nation</th>
                            <th class="">Alias</th>
                            <th class="">Customer Name</th>
                            <th class="">Media</th>
                            <th class="">GMDID</th>
                            <th class="">Headline</th>
                        </tr>
                    </thead>
                    <tbody id="tbody">
                        <% for(var i = 0; i < uploads.length; i++) { %>

                            <tr class="record">
                            <td><%= uploads[i]["itemkey"] %></td>
                            <td><%= uploads[i]["sendingdate"] %></td>
                            <td class="nationC"><%= uploads[i]['Nazione'] %></td>
                            <td><%= uploads[i]["alias"] %></td>
                            <td><%= uploads[i]["nomeCliente"] %></td>
                            <td><%= uploads[i]["media"] %></td>
                            <td><%= uploads[i]["publicationkey"] %></td>
                            <td><%= uploads[i]["publicationname"] %></td>
                        </tr>

                        <% } %>
                        <p id="counter"><%= i %></p>
                   </tbody>...

标签: javascriptmysqlnode.jshtml-tableejs

解决方案


推荐阅读