ekmungai / eloquent-ifrs

Eloquent Double Entry Accounting with a focus on IFRS Compliant Reporting
MIT License
334 stars 68 forks source link

Added indexes to transaction model #102

Closed hicka closed 2 years ago

hicka commented 2 years ago

Hey Edward. I have added the required indexes to the Transaction model in order to increase the performance while saving transactions. You wouldn't notice much of a difference at first while you're using without these indexes ( a few thousand transactions ) but once the transactions increase in size it slows down exponentially.

While saving a transaction, the code for generating a new transaction_no looks up these rows from the DB, making it slower for a new transaction to save without an index in a large transactions table.

FYI, the remove vat id column migration has some issues, it throws an error saying vats_vat_id_foreign key does not exist. I have a written a fix for that too.

Regards

ekmungai commented 2 years ago

@hicka Hi Hicka, Sorry for the delayed response. Regarding database optimizations, I'd deliberately left them out of the package so as to concentrate on the core logic of book keeping. That way devs can customize their optimizations according to whatever suites them and their chosen database engine the best. What do you think?

Cheers, Edward

hicka commented 2 years ago

Yes. 100% Agree with you on what comes first for this package, its the book keeping functionalities. While we are on it, i see no benefit of ignoring the performance improvements that could be made. How the performance improvements can be left to the devs is ok if they are willing to fork it and do their own customizations, as of right now there are no customizations to be made without altering the code of this package directly. I see this as a huge opportunity to make the package more robust, while making it a solid book keeping package why not optimize it further if we can?

hicka commented 2 years ago

Since code improvement is not a priority right now in this repo, i'll need to create a new repo with my fork and work on optimizations myself. If you have any concerns please do write me at hickr@me.com

Thanks and keep up the good work. Regards.