显示大型结果集 [英] Display large result set

查看:51
本文介绍了显示大型结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题:我需要存储 很多 条日志消息,并认为将其保存在 SQLite3 数据库中以便能够轻松搜索和过滤它是明智之举.

This is my problem: I need to store a lot of log messages and thought it would be smart to keep it in a SQLite3 database to be able to search and filter it easily.

我将在标准列表小部件中显示日志消息(使用 wxWidgets).该列表将包含多个列,并且可以由用户进行排序和过滤.

I will display the log messages in a standard list widget (using wxWidgets). The list will have several columns and can be sorted and filtered by the user.

现在,我不确定处理此问题的最佳方法是什么.我正在考虑一些可能的解决方案:

Now, I'm not sure what is the best way to handle this. I'm thinking about some possible solutions:

  1. 将所有消息读入内存.当有新的或更改的日志消息(在列表中的随机位置)时,必须刷新整个列表.当用户想要过滤列表或在不同的列上排序时也是如此.
  2. 将所有 ID 读入一个数组并按需检索完整的日志消息(当用户滚动列表以使其可见时).
  3. 使用 SQL 接口按需获取结果,使用 SQL 选择所需的确切子结果.

但实际上,我只是不习惯处理这种问题,所以感谢任何提示!

But really, I'm just not used to working with this kind of problem, so any tips are appreciated!

推荐答案

使用分页怎么样?

SELECT *
FROM logs
WHERE ...
ORDER BY ...
LIMIT offset, count

其中 offset 和 count 是您可以选择的值.您可以使用它来获取任意数量的日志条目.然后添加一个下一步按钮以允许用户查看下一页条目.结合过滤和排序的能力,日志搜索再简单不过了.

Where offset and count are values you can choose. You can use this to get any number of log entries. Then add a next button to allow the user to view the next page of entries. Combined with the ability to filter and a sort, the log search cannot be any easier.

这篇关于显示大型结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆