Skip to content
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

Discarding edits freezes qgis for a long time #18100

Closed
qgib opened this issue Feb 7, 2014 · 12 comments
Closed

Discarding edits freezes qgis for a long time #18100

qgib opened this issue Feb 7, 2014 · 12 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Vectors Related to general vector layer handling (not specific data formats)
Milestone

Comments

@qgib
Copy link
Contributor

qgib commented Feb 7, 2014

Author Name: Giovanni Manghi (@gioman)
Original Redmine Issue: 9509
Affected QGIS version: master
Redmine category:vectors


This is a follow up of #17922

Open a fair large vector like http://idena.navarra.es/descargas/CARTO1_Lin_6CNivelD.zip

with the field calculator update a column with whatever you want, then toggle editing and discard changes: QGIS freezes for a looooong time.

On the other hand with the provided dataset if you choose to save edits it takes just a few seconds to save.


Related issue(s): #17922 (relates), #18109 (duplicates)
Redmine related issue(s): 9315, 9519


@qgib
Copy link
Contributor Author

qgib commented Feb 8, 2014

Author Name: Jürgen Fischer (@jef-n)


Fixed in changeset "52616b6549bf43eee3cccc79f73aa890da5f3fab".


  • status_id was changed from Open to Closed

@qgib
Copy link
Contributor Author

qgib commented Feb 9, 2014

Author Name: Salvatore Larosa (@slarosa)


For me it still not fixed. I am getting always a QGIS freezing on rollback action.

@qgib
Copy link
Contributor Author

qgib commented Feb 9, 2014

Author Name: Jürgen Fischer (@jef-n)


Salvatore Larosa wrote:

For me it still not fixed. I am getting always a QGIS freezing on rollback action.

It's faster. But the changes need to be rolled back one by one and therefore the time it takes to rollback is somewhat the same as to do the changes in the first place.

@qgib
Copy link
Contributor Author

qgib commented Feb 9, 2014

Author Name: Matthias Kuhn (@m-kuhn)


It's not quite the same, as when doing changes the first time via the field calculator, one iterator is opened and looped while in a rollback, there is one iterator per feature.

Quote from #18109

As far as I can tell, there are feature requests made for every single feature which was updated before (so all in the case mentioned above).
I could imagine a possible approach would be to batch undo the affected rows and perform a single request with setFilterFids() to still only request the required rows, but with less roundtrips.


  • status_id was changed from Closed to Reopened

@qgib
Copy link
Contributor Author

qgib commented Feb 9, 2014

Author Name: Jürgen Fischer (@jef-n)


Matthias Kuhn wrote:

It's not quite the same, as when doing changes the first time via the field calculator, one iterator is opened and looped while in a rollback, there is one iterator per feature.

Not anymore. That was the case when the previous values were not stored in the first undo command - therefore the original value had to be retrieved from the provider using a iterator. Now that only happens if an attribute change happens when the previous value isn't already available (which is not the case in the field calculator).

Still all subscribers to the attributeValueChanged signal must be notified that the value was changed back (BTW the dualview form view doesn't update in that case).

@qgib
Copy link
Contributor Author

qgib commented Feb 10, 2014

Author Name: Matthias Kuhn (@m-kuhn)


Jürgen Fischer wrote:

Not anymore. That was the case when the previous values were not stored in the first undo command - therefore the original value had to be retrieved from the provider using a iterator. Now that only happens if an attribute change happens when the previous value isn't already available (which is not the case in the field calculator).

So the problem is the field calculator not saving the previous values?

Still all subscribers to the attributeValueChanged signal must be notified that the value was changed back (BTW the dualview form view doesn't update in that case).

I can take care of that. I think introducing an afterRollback signal should do the trick.

@qgib
Copy link
Contributor Author

qgib commented Feb 10, 2014

Author Name: Matthias Kuhn (@m-kuhn)


Ah, the form view and not the table view.

/me should read more carefully.

I will take care of this for 2.4 with the new editor components.

@qgib
Copy link
Contributor Author

qgib commented Feb 10, 2014

Author Name: Jürgen Fischer (@jef-n)


Matthias Kuhn wrote:

Jürgen Fischer wrote:

Not anymore. That was the case when the previous values were not stored in the first undo command - therefore the original value had to be retrieved from the provider using a iterator. Now that only happens if an attribute change happens when the previous value isn't already available (which is not the case in the field calculator).

So the problem is the field calculator not saving the previous values?

IMHO there is no problem anymore. The rollback is faster now, as it doesn't need to reload the values from the provider, but it still needs time because it needs to signal each undo - and that's by design.

We only have the attributeValueChange signal and subscribers can currently assume that they will be notified for each change. We could introduce a bulkAttributeValueChange signal (and undo command), that tells subscribers that all the values of an attribute changed (maybe include fid ranges or fid sets) and define that attributeValueChange doesn't cover bulk changes. But that would be a feature.

@qgib
Copy link
Contributor Author

qgib commented Feb 10, 2014

Author Name: Matthias Kuhn (@m-kuhn)


I am not at home to test now but when I tested yesterday it seemed to me that the field calculator is still faster than the rollback - and they should emit the same amount of signals. Maybe the decrease in performance is related to debug output the rollback produces.

bulkAttributeValueChange signal would be fine, but on the other hand I experienced that caching values retrieved from attributeChanged signals and postponing heavy operations to editCommandEnded() works very well. So the signals themselves seem to be a minor problem as long as their implementations are not performance-killers. The only remaining problem with this approach I can think of is that if several consumers cache the values it's a waste of memory.

@qgib
Copy link
Contributor Author

qgib commented Feb 10, 2014

Author Name: Jürgen Fischer (@jef-n)


Matthias Kuhn wrote:

I am not at home to test now but when I tested yesterday it seemed to me that the field calculator is still faster than the rollback - and they should emit the same amount of signals. Maybe the decrease in performance is related to debug output the rollback produces.

Before or after 52616b6? I didn't do benchmarking either, but the test expression to update and undo I used was trivial.

@qgib
Copy link
Contributor Author

qgib commented Feb 11, 2014

Author Name: Matthias Kuhn (@m-kuhn)


Tested again with current master.

I noticed, that when updating a column, the rollback is fast. But when I add a newly calculated column that's what takes so long to rollback.

In the latter case the debug output I mentioned is:

src/providers/postgres/qgspostgresconn.cpp: 825: (openCursor) Starting read-only transaction
src/providers/postgres/qgspostgresconn.cpp: 839: (closeCursor) Committing read-only transaction
src/providers/postgres/qgspostgresconn.cpp: 825: (openCursor) Starting read-only transaction
src/providers/postgres/qgspostgresconn.cpp: 839: (closeCursor) Committing read-only transaction
src/providers/postgres/qgspostgresconn.cpp: 825: (openCursor) Starting read-only transaction
src/providers/postgres/qgspostgresconn.cpp: 839: (closeCursor) Committing read-only transaction
src/providers/postgres/qgspostgresconn.cpp: 825: (openCursor) Starting read-only transaction
src/providers/postgres/qgspostgresconn.cpp: 839: (closeCursor) Committing read-only transaction
src/providers/postgres/qgspostgresconn.cpp: 825: (openCursor) Starting read-only transaction
src/providers/postgres/qgspostgresconn.cpp: 839: (closeCursor) Committing read-only transaction
src/providers/postgres/qgspostgresconn.cpp: 825: (openCursor) Starting read-only transaction

@qgib
Copy link
Contributor Author

qgib commented Feb 12, 2014

Author Name: Jürgen Fischer (@jef-n)


Fixed in changeset "5bee17218db3576a6a172eec5ef6d555fc023b4d".


  • status_id was changed from Reopened to Closed

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Vectors Related to general vector layer handling (not specific data formats) labels May 24, 2019
@qgib qgib added this to the Version 2.2 milestone May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Vectors Related to general vector layer handling (not specific data formats)
Projects
None yet
Development

No branches or pull requests

1 participant