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

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

问题描述

这是我的问题:我需要存储日志消息的批次,并认为将其保留在SQLite3数据库中可以很容易地搜索和过滤。 >

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



现在,我不知道什么是最好的方法来处理这个。我正在考虑一些可能的解决方案:


  1. 将所有邮件读取到内存。当有新的或更改的日志消息(在列表中的随机位置)时,整个列表将被刷新。当用户想过滤列表或排序在不同的列时,同样的事情。

  2. 将所有ID读取到数组中,并根据需要检索完整的日志消息(当用户滚动列表时)

  3. 使用SQL接口按需获取结果,使用SQL选择所需的确切子结果。

但是,真的,我不习惯使用这种问题,所以任何提示都不胜感激!

解决方案

如何使用分页?

  SELECT * 
FROM日志
WHERE ...
ORDER BY ...
LIMIT offset,count

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


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.

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. Read all messages to memory. When there is a new or changed log message (at a random position in the list) the whole list will have to be refreshed. Same thing when the user wants to filter the list or sort on a different column.
  2. Read all ID's into an array and retrieve the full log message on demand (when the user scrolls the list so that they are made visible).
  3. Use the SQL-interface to fetch the results on demand, using SQL to select the exact sub-result that is required.

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

解决方案

How about using pagination?

SELECT *
FROM logs
WHERE ...
ORDER BY ...
LIMIT 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天全站免登陆