cms
cms copied to clipboard
[3.x]: Performance issues loading a big table field in craft
What happened?
Description
I have a rare scenario where I have a big table field with ~30 columns that is filled with ~100 rows on one entry. Due to the size of this table it takes a while to render it, both on the front-end and in craft, however.. Rendering the table in Craft is nearly impossible as opening the page usually results into a timeout. (system report is all good)
Steps to reproduce
1 Create a big table, add 100 rows 2 Open page in Craft
Craft CMS version
3.7.37
PHP version
8.1.4
Operating system and version
Linux 5.10.47-linuxkit
Database type and version
MySQL 8.0.19
Image driver and version
Imagick 3.7.0 (ImageMagick 6.9.11-60)
Installed plugins and versions
No response
If you send your database backup + Composer files into [email protected], we can look into whether there’s any room to optimize, but I can’t promise we’ll make significant improvements anytime soon as Table fields weren’t designed with 30 column use cases in mind. Might make more sense to move that data into another section, and relate the entries with an Entries field.
As the field doesn't have to be editable in the CMS I decided to use a text field instead. Within this field I am saving my 'table' as json, the same way a real table field gets saved in the db. This still allows me to open the entry to edit the other fields. (would there be a better solution?)
If you still want to reproduce this issue: You can make a table field in any version of Craft and add ~ 3000 cells. I think the row and column ratio nor the cell content do not matter, I suspect the issue to simply be the rendering of the cells (+ input fields for each cell)
Yeah… editing that much data in a single Table field is definitely beyond the scope of what we built it for. I could see us addressing this down the road, but it will require a pretty major refactor.
Thanks for your reply! If it were up to me, this issue could be closed (or put on some kind of backlog), as it really isn't the intended use for the field.
I’ll leave it open just as something to reference back to if/when we get to this :)