-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve deep relations with PostgreSQL - transaction groups, notify, savepoints #97
Comments
Nice! This has been on my wishlist for a long time. I had a quick look and it sounds really good. I was especially happy to see that signalling more than just a simple "data changed" signal (dynamic applications driven by the database events) is being considered. Have you put some more thoughts into that already? In particular, did you think of a particular "signal signature convention" (something like |
Well, by now we thought about just implementing something very raw but using some structured text inside the message could be powerful for sure. I just have to check there is no limitation to the text formatting and length in the payload part of a NOTIFY, but that would be possible for sure. |
Mmm, maybe silly question, but having a database with 1.6 biljon measurements and flowing in new ones every couple of minutes; does this mean the datasource could be update in QGIS every time new measurements come in? Does this mean that the full (sub)query will be called? Or is there some way to dynamically maybe update the subquery (which is based both on extent and on a time-range)? |
Hi Richard, |
@haubourg thanks for answereing, but not sure :-) We normally show just 50000 features at a time (so a small subset of the full dataset), say the measurements of the last 10 hours (showing them using the timemanager). |
@rduivenvoorde to the best of my knowledge, a complete fetch is done on e.g. pan/zoom, even if some features are already there. Your request seems similar (at the filter level) to having qgis make a smarter query, or two queries: one for added + and one for "removed". It's out of the scope of what we initially planned, but an interesting idea nonetheless. |
@rduivenvoorde Ah ok, I understand now, and it reminds me the topics about caching data in QGIS to avoid fetching all the dataset, with all the hard questions about invalidating cache :)
NOTIFY could eventually be used as a system to notify a cache invalidation maybe, now you have to figure out how to send that message from PG. If you have tons of data being loaded every minute, a trigger on inserts or even update is probably not a good idea. Maybe you internal update procedure could explicitly cast the notify signal. Just wondering loudly, is it possible to create custom providers to test that ? I mean a DB provider caching data, loading only new data (how to filter new data then? using a sequencial id?) and caching it ? Notify signal would be the trigger for a new fetch for the whole dataset. In any case this is very specific to that particular database workflow. |
Hi all, |
QGIS Enhancement: Improve deep relations with PostgreSQL - transaction groups, notify, savepoints
Date 2017/06/22
Authors Régis Haubourg (@haubourg) / Vincent Mora (@vmora)
Contact regis.haubourg@oslandia.com
maintainer @vmora
Version QGIS 3.X
Summary
This QEP as been granted by QGIS.org 2017.
Since version 2.14, QGIS offers the not-so-well-known ability to handle transaction groups,
which means it can instantly evaluate triggers on database side, and refresh all layers in the
same transaction. This is a big win for usability, but some drawbacks glitches remain, such as
the lack of the undo/redo edit buffer, a very raw way of saving (ie quitting edition session) or
having the legend cluttered by so many edit symbols (a pen symbol).
Current proposal is to achieve the following targets:
Add a flag to allow dirtying edit buffer from the API when calling transaction.executeSQL('aSQLquery'). Currently, if nothing has been modified in QGIS layer, and we call a stored procedure (like
SELECT cut_pipe_on_xy('pipe_id', 'x', 'y');
), QGIS isn't aware that the dataset has changed, so the "save" action isn't available and users can only close edit session, which execute a ROLLBACK, and then obviously looses the current work.Restore an undo /redo feature by taking advantage of PostgreSQL. If possible we will try to
take advantage of PostgreSQL named Savepoints.
Allow to have some layers not switching to edit mode in QGIS, even if they belong to thesame connection. These layers will still benefit from the instant refresh, but won't clutter the
legend with the edit pen symbol everywhere, nor risk to load QGIS snapping cache for nothing.
Proposed Solutions
Dirty Edit Buffer on ExecuteSQL
WIP
UNDO/REDO on SavePoints
A first PR is drafted here: qgis/QGIS#4765
NOTIFY / LISTEN
UI modifications proposed are
A new checkbox to allow refreshing a layer when a signal is emitted. It has a line edit widget to add an optional filter for the message carried by the NOTIFY. The layer will be refreshed only if the NOTIFY message matches.
Example(s)
Any operational application where data can be modified somewhere and where QGIS needs to be notified without having to constantly refresh layers.
Affected Files
ui/qgsvectorlayerpropertiesbase.ui
ui/qgspgnewconnectionbase.ui
..
Performance Implications
NOTIFY/ LISTEN requires QGIS to have a permanent connection to PostgreSQL opened to keep listening the NOTIFY messages. Users must be aware that this will consume some more available connections in the connection pool.
Also using a connection pooler like pg_pool should be tested to be sure connections are not closed unexpectedly from the pooler side.
Further Considerations/Improvements
(optional)
Backwards Compatibility
This work is only intended to QGIS 3 branch and is not supposed to break compatibility
Issue Tracking ID(s)
(optional)
Votes
(required)
The text was updated successfully, but these errors were encountered: