Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 208649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:50:40+00:00 2026-05-11T17:50:40+00:00

I have a SQLite database that contains a huge set of log messages. I

  • 0

I have a SQLite database that contains a huge set of log messages.

I want to display this in a list view (using wxWidgets).

The user can reorder the list (by pressing the column header), apply a filter on the result set and navigate through it as a usual list, using the scroll bar. The user can also select one or multiple entries in the list and delete them.

I have a virtual list model: the list view asks the model for the content of a particular row. The model issues a select-query with the current filter-conditions and order and returns the corresponding row from the result.

To make it faster I keep page-caches of results: when a row is requested i fetch a whole page (~100 rows) using LIMIT and OFFSET and return the particular row from the page. I store a number of pages, and next time a row is requested I first look if it is available in one of the cached pages. This technique has proven to be fast and responsive even with lots of entries (50k+).

The problem

My problem is how to handle updates/inserts/deletes. I have one trigger for each so the model is notified whenever an insert/update/delete happens. The trigger also tell the model the ID (primary key) of the affected entry.

My first version simply made a complete reset of the model after each trigger. This was not very fast, but fast enough. The problem was that if the user had made a selection of one or a couple of rows, the selection was lost.

The base class of the model (wxDataViewVirtualListModel) contains methods that should be called when a change happens:

  • RowInserted (row)
  • RowDeleted (row)
  • RowChanged (row)

If I used them the selection problem would be solved, however there are problems:

  • How do I know if the changed row is within the currently filtered set?
  • How do I know which row in the list view was affected?

The first problem could be solved by creating a method that check if the entry belongs to the set. It must behave exactly like the SQL-conditions, but it is doable.

The second problem I have simply no idea about how to solve.

I’ve used a bogus (0 or last row) row-number to force the view to be updated, but the problem is if the row was inserted/deleted before the selection, the selection points to wrong rows afterwards, and so on.

How would you do? Keep an advanced data structure with all entries in memory?

This question is related to another question:
Display large result set

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:50:40+00:00Added an answer on May 11, 2026 at 5:50 pm

    I would design this around two different SELECT operations, one getting only the primary key and a timestamp (of the INSERT / UPDATE) for all rows, the other getting all data for a single page of rows. On a modern machine keeping the complete list of primary keys and timestamps in memory should not be a problem even for several 100000 rows.

    Whenever the filter criteria change or a trigger fires I would retrieve the list of primary keys and timestamps again. The model maintains a list of primary keys and matching timestamps, and a comparison between the model and the new list shows which rows need to be inserted, invalidated or removed. Cached rows whose timestamp has changed get deleted from the cache, cached rows with the same timestamp need not be retrieved again. The oldest entries of the cache would be removed when it gets too large.

    The selection of the list can be identified via its primary key value, so unless the row has been deleted it is always possible to reselect it after changes to the model, even when it is now in a completely different position. I find this to be much more intuitive than keeping the same row position when the ordering changes, which selects a completely different row.

    Edit:

    This works for concurrent data changes from other database clients, I have implemented it this way for applications using the Firebird database server. If there’s no way the data can be changed from outside it may not be necessary to always retrieve the full list of primary keys and timestamps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database file that is generated on a PC using Sqlite. This
I have a component that i want to store to an SQLite database. public
I have a datalogging application (c#/.net) that logs data to a SQLite database. This
If you want to pre-populate a database (SQLite) in Android, this is not that
I have a file name database.sqlite which contains data that I have to use.
I have a database that contains decimals. The column is set up as ..
I have a description column in my SQLite database that contains some text to
I have a SQLite database that has a time field set as a text
I have a Java web service that is querying a SQLite database that contains
I have an app that must get data from the Sqlite database in order

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.