-
Notifications
You must be signed in to change notification settings - Fork 5
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
Ensure _revision_expired is always > _revision_created #121
Conversation
@imincik do you want to give this change a try and see how much does it affect performances ? |
@strk , I would be interested if there are any other similar checks we can introduce. |
I added @dwsilk to reviewers. I can test it in BDE Processor for performance penalty, but I am not sure if it will cover all use cases. |
@imincik yes, I think we could also introduce a foreign key constraint to make sure revisions used in _revision_created and _revision_expired DO exist in table_version.revision, but I wanted to first verify the performance change with just this single constraint |
Okay so this should really only affect Basic test to compare performance over 10,000,000 records with bare minimum data:
Result:
I would guess that BDE processor performance is the most important application that we can test. The amount of data in queries for other applications of this extension at LINZ is minimal in comparison. |
Yes it should only affect INSERT/UPDATE (while foreign key constraint would also affect DELETE on the referenced table) - those hits seem ok to me, especially as for BDE processing the inserts and updates would be MORE expensive because there would be more data to write, while the cost of comparing _revision_expired and _revision_created would be fixed... |
Thanks for the review, see how you like 721ba11
|
Thanks for approval.
What this PR does NOT include is an easy (automatic?) way to
add the check to existing revision tables. Tables with corrupted
records would fail to get the addition of such check so it may be
useful to have a callable function to try at adding missing
checks, raising a WARNING wherever such addition fails.
|
I will test this PR with level_5 update. @strk , please wait with merge until this is done. |
I just started performance test of this patch (running level_0 without patch). Might be done in 4 days from now. |
@strk , level 0 processing using latest released packages, without tested patch, finished with following error:
Ticket created: https://app.zenhub.com/workspace/o/linz/bde-processor-deployment/issues/307 |
Make sure the user who prepares the database (with table_version 1.5.0+) or the user who runs the upload (with table_version up to 1.4.x) is a superuser, or has permissions to write into pg_depend. Example query: |
This issue has been automatically marked as stale as there has not been any activity for sometime. The issue will be closed in 14 days if no further activity. |
This issue is still relevant. |
This issue has been automatically marked as stale as there has not been any activity for sometime. The issue will be closed in 14 days if no further activity. |
It took 35147012.330 ms (9.7630 hours) to run |
Where are you running those tests ? LI-exp ? Looks too long, maybe somebody was running something else there as well. |
Completed same run (yes, on li-exp) with this PR applied. Took 42038905.988 ms (~11.6 hrs) |
Hm, look very slow ... |
We could try an |
Forget the last comment, it'll probably be slower to defer the check. |
I've pushed a commit adding the constraint to already-versioned tables. |
@@ -67,6 +67,7 @@ BEGIN | |||
'CREATE TABLE ' || v_revision_table || '(' || | |||
'_revision_created INTEGER NOT NULL,' || | |||
'_revision_expired INTEGER,' || | |||
'CONSTRAINT expired_after_created CHECK ( _revision_created < _revision_expired ), ' || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need an OR _revision_expired IS NULL
check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment
Closing because of no feedback. Please reopen if this can still be merged. |
Closes #78