Invoice Updating very slow

Noticing long wait times when updating invoices or other items in the system after migrating to v5.

For example, updating an existing invoice in the system is taking 8+ seconds for a TTFB response:


This is on a VPS server that performs very well with all other sites hosted on it so I don’t believe it’s tied to resources?


What method are you using to generate the PDFs?

cc @david

Hi, I experience slow response times as well. After enabling the Slow query log in Mysql, it looks like a bottle neck there. I use SnapPDF to make invoices, the server OS is CentOS 8 running PHP 7.4 with Apache. Small tasks like deleting an invoice will return in a couple seconds, while adding line items to an invoice could take over a minute.

Are there any ideas why some queries would take so long? Appreciate any help,

Are all slow responses related to PDF generation, it may explain the bottleneck.

Not just related to PDF, all tasks are slow and related to Mysql as evident by the slow query log. I have other sites like Ninja4, Wordpress, Django that all make queries in the millisecond range. I have two Ninja5 instances installed on this server and they are both slow to respond thru Mysql.

Here is an example from the slow query log that is set to show queries over 10 sec. This query took 10.8 sec.

# Thread_id: 15957 Schema: russ_ninja5_2 QC_hit: No
# Query_time: 10.825493 Lock_time: 0.000094 Rows_sent: 0 Rows_examined: 1
# Rows_affected: 1 Bytes_sent: 52
use russ_ninja5_2;
SET timestamp=1624382881;
update clients set balance = ‘1’, clients.updated_at = ‘2021-06-22 17:27:50.275616’ where id = 6;

I think this simple query should not take so long, do you have suggestions for how to debug it? Thank you

On the topic of PDF, I thought SnapPDF was the preferred method? If not, which PDF generator is preferred?

@david do you have any suggestions?


That query should run quite fast. I think there may be something else blocking.

Yes SnapPDF is the preferred PDF generator.

Thanks for confirming the speed,
I checked process log while some users are making changes in Ninja5 – it’s the only thing demanding of mysql.

I will turn on general log in mysql and see what it’s doing. Are there any tools inside Ninja that could help with tracking this issue?