页面加载后从数据库填充数据网格列

发布于 2024-07-08 23:53:15 字数 557 浏览 6 评论 0原文

我有一个网页,通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

§普罗旺斯的薰衣草 2024-07-15 23:53:15

为用户提供是否显示额外列的选项。 然后有两个可以绑定到 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文