Laravel-Backpack / community-forum

A workspace to discuss improvement and feature ideas, before they're actually implemented.
28 stars 0 forks source link

Select field (without attribute allows_null) makes page load slow #680

Closed Ronnos closed 6 months ago

Ronnos commented 1 year ago

Hello,

While debugging my loading times, I noticed that the select and select_from_array field makes loading slow (+2-3seconds) when the attribute 'allows_null' is missing. Is there any explanation for?

Kind regards, Ron

pxpm commented 1 year ago

Hey @Ronnos the reason is that if you don't specify it, Backpack will try to infer it from the DB column, thus taking a bit longer https://github.com/Laravel-Backpack/CRUD/blob/4dc36a3f8020bca9061177336b4dd65b54795352/src/resources/views/crud/fields/select_from_array.blade.php#L2

But ... I think we had created the schema manager to deal with cases like this, avoiding multiple queries.

The reason is the one I told you, but I will investigate if somehow we are missing the Schema and querying the db everytime. If that's the case I will consider this a bug and fix it 🙏

Thanks @Ronnos

Cheers

Ronnos commented 1 year ago

Well, I think you are right... When adding multiple select fields it doesn't add up the loading time... Only the first field without attribute will contribute to increasing loading time... However; inspecting all queries I don't see an extra query when there is no attribute that checks Schema...

Goodluck debugging 🙏 !

pxpm commented 6 months ago

This should be fixed in the latest version. 6.7.3.

I've just tested adding a select_from_array field with/without allows_null and couldn't spot any noticeable difference, even more 2~3s difference.

It is also possible that it could be a mysql version issue, I tested using 8.0+. It's worth checking if you are not running an old 5.7 or something similar.

I am going to close this, please let me know if you are still experiencing this issue. In case you do, can you provide me more detailed instructions on how I could reproduce this, plus your environment details, php, mysql etc?

Cheers