javascript - 非常慢的交互与大量数据负载
问题描述
我用节点开发了我的应用程序,该节点在页面上应该加载 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>...
解决方案
推荐阅读
- java - 使用 JTable 和列按钮从数据库中删除正确行的问题
- r - 如何在全局环境中查找与对象名称中的两个下划线模式匹配的对象
- iphone - 树莓派蓝牙文件服务器
- ios - 带有顺序和限制的 Firestore 复合查询
- vim - 不同语言和任务的不同vim文件
- python-3.x - 在由字典组成的数据集上,如何将每个字典的元素与 Python 相乘'
- swiftui - 为什么嵌入到 SwiftUI 表单中的按钮不起作用?
- c - 如何在没有 strlen()、sizeof(arr) / sizeof(arr[0]) 的情况下获取这个数组的长度;不行,C语言
- python - TypeError:“模块”对象在使用 selenium webdriver 打开 chrome 浏览器时不可调用
- javascript - Eslint:警告文件默认被忽略。使用否定忽略模式