Replies: 1 comment 2 replies
-
|
Hi @chbister, The delay you’re seeing when saving a new invoice is likely due to how the next sequential serial number is generated. To determine the next serial number, the system runs this query: public function getPreviousInvoice(): ?static
{
/** @var ?static $invoice */
$invoice = static::query()
->withoutGlobalScopes()
->where('serial_number_prefix', $this->serial_number_prefix)
->where('serial_number_serie', $this->serial_number_serie)
->where('serial_number_year', $this->serial_number_year)
->where('serial_number_month', $this->serial_number_month)
->latest('serial_number_count')
->first();
return $invoice;
}If you have only one series, adding an index on these columns can significantly improve performance: $table->index([
'serial_number_prefix',
'serial_number_serie',
'serial_number_year',
'serial_number_month',
]);This should make generating the next invoice number much faster. Let me know if it helps |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
During my mass invoice import (approx. 40000 invoices) I experienced that the save() method takes longer and longer the more invoices are stored (90 seconds and even more).
Now I am curous: is it my setup or is it something else that I am not aware of?
Any feedback is appreciated.
These are my benchmark results:

This is my command to do the benchmark:
Beta Was this translation helpful? Give feedback.
All reactions