页面加载后从数据库填充数据网格列
我有一个网页,通过 SQL 查询将一些数据加载到数据网格中。 我被要求添加一个新列。 在测试过程中,我发现从数据库中提取这一额外的数据列会大大减慢查询速度。 过去需要亚秒级的查询,现在只需大约 3-4 秒。 我已经检查了数据库,所有适当的索引都已就位,并且数据库更改在这里不切实际。
无论如何,页面加载速度减慢确实会影响生产力。
如果可能并且可行的话,这就是我想做的。 我想像以前一样使用原始查询渲染数据网格,但将额外列留空。 然后在页面渲染后使用 Ajax 返回服务器并获取剩余列的数据并填充它。 这样,那些不需要额外列来完成工作的用户就不必等待页面渲染那么长时间,但那些需要它的用户只需等待几秒钟,数据就会在那里。
问题是,我完全不知道如何将它们组合在一起。 有什么建议么?
I have a web page that loads some data via a SQL query into a datagrid. I was asked to add a new column. During testing I discovered that pulling this extra column of data from the database slows the query down substantially. What used to be a sub-second query now takes about 3-4 seconds. I've checked the database and all the appropriate indices are in place, and a database change wouldn't be practical here.
Anyway the slow down in the page loading could really impact productivity.
If it's possible and practical, this is what I would like to do. I'd like to render the datagrid as before with the original query, but leave and extra column blank. Then after the page is rendered use Ajax to go back to the server and get the data for the remaining column and populate it. That way, those users who don't need the extra column to do their work, don't have to wait so long for the page to render, but those who need it can just wait a few seconds and the data will be there.
The problem is, I don't have the faintest idea how to put this together. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为用户提供是否显示额外列的选项。 然后有两个可以绑定到 GridView 的查询,一个返回额外列,另一个不返回。 然后由用户决定他们想要哪个“视图”。 这样他们就不必在每次打开或刷新页面时都做出决定,您可以保留他们的选择。
Give the user an option to display the extra column or not. Then have two queries that can bind to the GridView, one that returns the extra column and one that doesn't. Then it is up to the user to decide which "view" they want. So that they do not have to decide every time they open or refresh the page, you persist their selection.