[Html2PdfConverter] Slow queries when trying to fetch binary from database

Forge Component
Published on 5 Feb by Miguel 'Kelter' Antunes
69 votes
Published on 5 Feb by Miguel 'Kelter' Antunes

Hey guys,

So I noticed something weird on our production server, we generate alot of PDF's, like 1000+ a day.
And we have quite some performance issues, we found out that querying the executablebinary entity is very slow. Around 1.5 seconds every call. This means for every PDF we generate we have to wait atleast 1.5 seconds. (on development, which is a weaker server, this entails about 20 seconds).

I'd love for this component to be able to handle 1000+ pdf's a day without destroying the user experience of the end users.

Currently I added some caching myself, which helps a bit.

Hello just to make sure, you probably already have this good practice build in your architecture but, are you creating a table separately from the data and only get binary by id? With this you don't blow up the memory and increase performance executing query.

I am sorry if you already have this kind of structure build it is just a problem that happen to other people.

I'm talking about the code inside the component itself.

I'm not storing the generated binaries in the database.

Hi Joey,

Thanks for the feedback. 

If you open the component you'll see that it is as much optimized as possible and it stores the binaries on the local filesystem the first time (and only that time it queries the table you're mentioning) and after that it uses it without going to the DB.

So the 1.5s penalty you're seeing should only happen once.

Are you seeing in your logs slow queries to the GetPDFGeneratorBinary query for all generated pdfs?



Hey Guilherme,

Take a look at the following screenshots:

This arrow pointing to the aggregate that is causing this 1.5 second delay.

If it found an entry, it will check if the file exists, if so it skips this part.
Though, this aggregate always fetches the binarydata aswell, it could be an idea to only fetch the binary if the file is not found on the server?


Hi Joey,

The query does not fetch the binary as the Executable table does not have it (it's in the ExecutableBinary table).

Can you share your SLOW QUERY logs?




Oh no. It seems I got an older version :(

Haha, nevermind this thread, I'll download the latest version.