New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chunk the tokens array to avoid making extremely long queries. #17390
Conversation
007281a
to
bf13859
Compare
Status is set on "Needs Review". |
bf13859
to
cb3f12c
Compare
Rebased with latest staging. I can't imagine why that drone test is failing. There's nothing in this code that would cause it to fail. |
Hmm. So, is this getting in? Because this is a legit problem that people in the real world may actually face. |
If it gets tested, sure. Looking at this again reminded me of something though. There's already a similar (yet less elegant) implementation of this in the SQL Server subclass and I think it essentially is the same thing, so it looks like the overriding method can be removed. |
Yeah, that's weird. Someone noticed this could happen with SQL Server but didn't think it would ever be a problem for other dbs? Anyway, I can remove that override and include it in this PR if you want. |
That was me. SQL Server actually has (had? this was SQL Server 2008) a hard query limit of inserting 1000 values in a query which is why I had to do the override for that driver. |
cb3f12c
to
a972a11
Compare
Rebased with latest staging and went ahead and removed that redundant override. |
Just need one more approval... |
I have tested this item ✅ successfully on a972a11 Tested and did code review too, i am using similar code for updating DB in a faster way, This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17390. |
I have tested this item ✅ successfully on a972a11 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17390. |
Ready to Commit after two successful tests. |
Pull Request for Issue # .
Summary of Changes
Chunk the tokens array (which can potentially be very long) before using it to generate a query. Run a query for each chunk instead of the whole array.
Testing Instructions
max_execution_time
is something sensible like 30 seconds.Expected result
Well, I expect the article to save properly and the page to reload without crashing.
Actual result
Most likely, the article will save but in the post-save indexing process there will be a timeout. This happens because we are looping over a huge array of tokens and adding each one to the
values
array of the query object. The query object handles this rather inefficiently (should be addressed in a different PR) but is mostly fine until thevalues
array gets very large.One solution is to avoid getting a huge
values
array by sending several smaller queries instead of one big one. This is that solution.Documentation Changes Required
nope