Ticket #161 (new task)

Opened 3 years ago

Last modified 10 months ago

LiveQuery

Reported by: amir Assigned to: glyph
Priority: lowest Milestone:
Component: Axiom Severity: normal
Keywords: Cc: mithrandi
Author: Branch:

Description

Current Queries are static: they represent the state of the db at the time the query was made. This is fine, but not always what we want.

In certain cases we want to make a query and get the state of the db as of that point in time AND we want to be notified of any Items that get created from this point on that match the query. Items can come into "focus" for a query in one of 2 ways: either by being created just right or by having some attributes change on an existing item to bring it into focus.

Atop Pools use to do itemAdded/Removed/Changed notification and we need something similar for Axiom.

This feature can be accomplished by polling, but we hate polling.

Use cases: livequery on folks wanting help with Breezy install; livequery of people in the neigbourhood; livequery or email from family

Attachments

rwall_livequery.patch (3.0 kB) - added by rwall on 01/27/06 13:08:16.
A very basic start at using louie (http://louie.berlios.de/) for livequery

Change History

12/06/05 06:41:39 changed by njs@pobox.com

Items can go out of focus too, from delete or update.

I was thinking about this a bit, and at first blush, the only generally viable strategy seems to be to just re-run queries when things could have changed.

If a query has no join in it, then each time you insert/delete/update an item in the relevant table, you can check it against your condition explicitly and add it to or remove it from your result set.

If a query has a join in it, then the only useful invariant I can think of is that modifications to tables that aren't involved in the join can't affect the results. But any modification that touches those tables might, in arbitrarily complex ways. (I dunno if we hit the halting problem here, but it actually seems marginally plausible.)

This requires keeping the old result set around somehow. This could just be done in memory; a reasonably slick alternative, without the unbounded memory use, would be to stick it in a temporary table. (SQLite stores these on disk, in unlinked files.) Then you can directly select everything matching the query that is not in the other table, for instance, using EXCEPT or subselect; or just do a query on each, iterate over them in parallel to find added/removed items in a single pass with constant memory overhead.

12/13/05 02:52:23 changed by glyph

  • priority changed from normal to low.

01/27/06 13:08:16 changed by rwall

  • attachment rwall_livequery.patch added.

A very basic start at using louie (http://louie.berlios.de/) for livequery

05/31/06 10:11:24 changed by mithrandi

  • cc set to mithrandi.

08/10/07 13:33:11 changed by glyph

  • milestone deleted.

09/14/07 18:27:37 changed by glyph

  • priority changed from low to lowest.

OK on further consideration I have no freaking idea how this is going to work. One day, though, one day...

jethro@divmod.org