- Issue created by @prudloff
- @prudloff opened merge request.
- Status changed to Needs review
over 2 years ago 5:18pm 27 March 2023 - Status changed to Needs work
over 2 years ago 12:41am 28 March 2023 - πΊπΈUnited States smustgrave
Sounds like a valid use case.
Can we add a kernel test maybe to make sure they come out alphabetically.
- π΅π±Poland artemboiko
Caught the same problem, thanx for saving time.)
- First commit to issue fork.
- Merge request !8633Issue #3350704: Order strings from the database alphabetically by source and then context β (Open) created by tgauges
- π©πͺGermany tgauges
I created a new branch against 11.x which first sorts the translations by their source string and then the context. The context is needed for equal source string with different context.
Before review, the test should be extended to also test the case for equal source strings but different context.
- π«π·France prudloff Lille
prudloff β changed the visibility of the branch 3350704-order-translations-alphabetically to hidden.
- πΊπΈUnited States smustgrave
Removing the tests tag as https://git.drupalcode.org/issue/drupal-3350704/-/jobs/4589844 shows the coverage
See no issue with ordering these.
- π¬π§United Kingdom catch
I think this might need a new database index - see note on the MR.
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
We need to add an index then to avoid the `using filesort` - thanks @tgauges
- π©πͺGermany tgauges
What kind of index needs to be added to "avoid the
using filesort
"?I read a bit of MySQL ORDER BY Optimization but my experiments did not result in the avoidance of
using filesort
when runningEXPLAIN SELECT s.* FROM locales_source s ORDER BY s.source ASC, s.context ASC;
.I tried the following on 10.11.11-MariaDB-ubu2204-log:
- Change the existing index
(source(30), context)
to(source(2048), context)
. - Add a new index
(source(2048))
. - Add a new index
(context)
.
The largest context value in my database is 1452 queried with
SELECT length(source) AS length FROM locales_source ORDER BY length DESC;
. - Change the existing index
- πΊπΈUnited States smustgrave
Hello @tgauges first appreciate taking on this task!
Since this seems to be still in discussion moving to NW, discussions can still happen without being in review
- π©πͺGermany tgauges
@smustgrave sorry, my bad.
Since a usable index might not be possible I adjusted the merge request to only add the
ORDER BY
statements when multiple strings are loaded.This too might not be acceptable. In that case, I propose a function API update so that callers can decide via parameter whether they want the translations sorted or not.
Another option might be to make the
\Drupal\locale\StringDatabaseStorage::dbStringSelect
function public so that the query can be adjusted and executed at will.