wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Fixes #5416 Reduced UsedCss index key size

Open CrochetFeve0251 opened this issue 2 years ago • 7 comments

Description

Fix a bug at the creation from the RUCSS table due to the index key being too long. For that we reduced to 191.

Fixes #5416

Type of change

  • [ ] Bug fix (non-breaking change which fixes an issue)

Is the solution different from the one proposed during the grooming?

No.

How Has This Been Tested?

  • [ ] Manually

Checklist:

Please delete the options that are not relevant.

  • [ ] My code follows the style guidelines of this project
  • [ ] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] My changes generate no new warnings
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] New and existing unit tests pass locally with my changes
  • [ ] Any dependent changes have been merged and published in downstream modules

CrochetFeve0251 avatar Sep 13 '22 20:09 CrochetFeve0251

@Tabrisrp What do you think about reducing the size here: https://github.com/wp-media/wp-rocket/blob/c6b74a8ad463158511a7d10352554379d4731099/inc/Engine/Optimization/RUCSS/Database/Tables/UsedCSS.php#L68

That's what @engahmeds3ed suggested at some point, not sure if that works and which option is better/cleaner.

piotrbak avatar Sep 14 '22 13:09 piotrbak

It really depends on the possible length of the queue_name values, do we know how long it can be?

remyperona avatar Sep 14 '22 13:09 remyperona

From what I can see, we should not expect this value to be long: image

piotrbak avatar Sep 14 '22 13:09 piotrbak

Makes me wonder why the queue name is indexed in the first place, we don't query based on it in the plugin. Looking at the code, I think there was a mistake at some point, making this an index instead of the status column.

remyperona avatar Sep 14 '22 13:09 remyperona

Makes me wonder why the queue name is indexed in the first place, we don't query based on it in the plugin. Looking at the code, I think there was a mistake at some point, making this an index instead of the status column.

Ok I think for that I will have to update the schema for all customers but I agree it is weird to index on that value.

CrochetFeve0251 avatar Sep 14 '22 14:09 CrochetFeve0251

Since it's scheduled for 3.12.2 we have some time for discussion.

making this an index instead of the status column.

Which queries would take advantage of this change? 🤔

piotrbak avatar Sep 14 '22 14:09 piotrbak

We have some queries that are based on the current status, so if there is a lot of entries, they could be faster

remyperona avatar Sep 14 '22 14:09 remyperona

@CrochetFeve0251 When installing WP Rocket from scratch indexes look fine.

However, updating WP Rocket from a previous version changes the queue index to status but it doesn't have the 191 length restriction.

I believe this is coming from here:

https://github.com/wp-media/wp-rocket/blob/35a401ed45acb41d42e19943f1030d3b5cb618ae/inc/Engine/Optimization/RUCSS/Database/Tables/UsedCSS.php#L216

Can you please look into this? 🙏

vmanthos avatar Oct 10 '22 11:10 vmanthos