-
Notifications
You must be signed in to change notification settings - Fork 4
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 kassenbuch speed #138
Conversation
Current coverage is 28.22%
@@ development #138 diff @@
=============================================
Files 54 54
Lines 6709 6756 +47
Methods 0 0
Messages 0 0
Branches 0 0
=============================================
+ Hits 1820 1907 +87
+ Misses 4889 4849 -40
Partials 0 0
|
elif until_date: | ||
query = query + " WHERE datum < Datetime('{until_date}')".format( | ||
until_date=until_date | ||
) |
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.
Since it is exactly the same code as above (lines 370-381), why not make a "where query generator" function, which can be reused?
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.
Good idea, I will look into it.
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.
Done :-)
A cache of the sums would be another improvement, significantly speeding up The cache should be kept separate, at least a separate table if not a separate database. |
Wouldn't computing the sums for summary_to_string in the database be faster? (Instead of creating the In a next step we could use a SQL-trigger to automatically compute the sum of all or certain entries on update of the table. For this to be useful we however have to come up with a scheme of how to use it. |
With 3dad868 I have added trigger that record the date of last change in a table. We could then check the timestamps against the timestamp of a cache. This way we can keep the cache as long as no change has been made to the database. |
before you start caching things in seperate tables, use sql-queries instead of objects to crawl over. I can think of such a query:
If the Group-by is too slow, an option would be to outsource the to get the newest
Since i have no filled database to play with, i could not verify or test things, when fuzzing in the code... |
I would strip 3dad868 from this PR and the merge it. OK? |
We cannot do SUM in the database because we use Decimal and sqlite uses float. |
3dad868
to
62b754c
Compare
I have removed the mentioned commit and would now say that this is ready to merge. |
now would be a good point to add a few tests that cover the date filtering and sum calculation. |
in the meantime i have got a populated database to play with and have implemented the above mentioned query. it works fine in the sense of displaying the same results as the former object-crawl version. By this i got the execution time from 1.2s down to under 0.25s. I agree to the problems of summing up many float values. But when this is a mission-breaker, i would move away from sqlite to a more sophisticated database-engine like mysql/mariadb or postgres, that have decimal maths build in. Testing: I can imagine to provide a "test database" file with special values inserted and asserting against a preprocessed result. the values include some corner cases like a buchung with the exact datetime of an |
I think the existing unittests should be amended to generate test data by making bookings and running queries. |
And for the generation of data the package hypothesis should be used. This makes it easier to write tests that do not make too much assumptions. |
62b754c
to
0e617f7
Compare
beb28a9
to
a5913c6
Compare
I have added some basic unittests they should be enough for now. |
Deployed to Kasse. |
Nachdem der Julian von der Kassenbuch-Performance begeistert war, ich auch und überhaupt alle, haben @schrolli und ich uns hingesetzt und ein paar einfache Perfomance-Upgrades eingefrickelt :-)
Ich bitte um ein Review, da es auf der Datenbank rumschreibt :-P