#90143Redirects: Poor performance of redirect matching for large redirects table
Description
Problem description
The current redirect matching retrieves all redirects from the database table and stores it in an internal cache.
This is then fetched and filtered for the route that matches the request.
- https://github.com/TYPO3-CMS/redirects/blob/master/Classes/Service/RedirectService.php
- https://github.com/TYPO3-CMS/redirects/blob/master/Classes/Service/RedirectCacheService.php
With a large redirects table this takes a pretty long time.
I created 350.000 unique redirects and it took the page about 5 seconds to redirect to the target page.
Before you say “350.000 will never be reached”: On a long term a heavily edited website might reach that number at some point in time (assuming this feature will continue to exist with further TYPO3 versions).
Suggested solution
I suggest that the redirect matching is mainly done via the database query.
Most of the logic can be moved into a WHERE clause. Operations which are not available via database operations would then be applied to the remaining records.
With that the above 5 seconds of loading time could be reduced to merely 1 second.
This might also imply that the redirect cache via RedirectCacheService is not needed anymore.
Databases already come with caching mechanisms, as to such I fail to understand why a PHP cache is also needed.
This is a perfomance improvement which should be applied to TYPO3 9.5 as well.
Reviews 2
Related issues 4
Files 1
History 729
Show 14 earlier messages
-
Gerrit Code Review pushed patch set 1 for master to change 62956 status
NewUnder Review <span data-processor="relativetime" data-value="2020-01-17T16:49:10+00:00" > 01/17/20, 16:49 </span> -
Gerrit Code Review pushed patch set 2 for master to change 62956 <span data-processor="relativetime" data-value="2020-01-17T16:51:55+00:00" > 01/17/20, 16:51 </span>
-
Gerrit Code Review pushed patch set 3 for master to change 62956 <span data-processor="relativetime" data-value="2020-01-17T16:53:47+00:00" > 01/17/20, 16:53 </span>
-
Mario Lubenka commented and changed attached redirect-measure-time.ods <span data-processor="relativetime" data-value="2020-01-20T15:36:57+00:00" > 01/20/20, 15:36 </span>
-
Mario Lubenka commented <span data-processor="relativetime" data-value="2020-01-20T15:38:54+00:00" > 01/20/20, 15:38 </span>
No additional indexes needed.
-
Gerrit Code Review pushed patch set 4 for master to change 62956 <span data-processor="relativetime" data-value="2020-02-15T14:09:44+00:00" > 02/15/20, 14:09 </span>
-
Gerrit Code Review pushed patch set 5 for master to change 62956 <span data-processor="relativetime" data-value="2020-02-15T14:18:23+00:00" > 02/15/20, 14:18 </span>
-
Gerrit Code Review pushed patch set 6 for master to change 62956 <span data-processor="relativetime" data-value="2020-02-15T14:37:41+00:00" > 02/15/20, 14:37 </span>
-
Gerrit Code Review pushed patch set 7 for master to change 62956 <span data-processor="relativetime" data-value="2020-04-07T00:38:08+00:00" > 04/07/20, 00:38 </span>
-
Gerrit Code Review pushed patch set 8 for master to change 62956 <span data-processor="relativetime" data-value="2020-04-07T00:43:36+00:00" > 04/07/20, 00:43 </span>
-
Sybille Peters changed Related to #93287 <span data-processor="relativetime" data-value="2021-01-14T07:51:09+00:00" > 01/14/21, 07:51 </span>
-
Sybille Peters changed Related to #93547 <span data-processor="relativetime" data-value="2021-02-19T07:01:42+00:00" > 02/19/21, 07:01 </span>
-
Daniel Goerz changed Related to #91792 <span data-processor="relativetime" data-value="2021-03-19T09:23:00+00:00" > 03/19/21, 09:23 </span>
-
Gerrit Code Review pushed patch set 9 for master to change 62956 <span data-processor="relativetime" data-value="2021-09-07T10:29:36+00:00" > 09/07/21, 10:29 </span>
-
Gerrit Code Review pushed patch set 10 for master to change 62956 <span data-processor="relativetime" data-value="2021-09-11T12:57:55+00:00" > 09/11/21, 12:57 </span>
-
Gerrit Code Review pushed patch set 11 for master to change 62956 <span data-processor="relativetime" data-value="2021-09-11T13:16:27+00:00" > 09/11/21, 13:16 </span>
-
Gerrit Code Review pushed patch set 12 for master to change 62956 <span data-processor="relativetime" data-value="2021-09-11T21:50:39+00:00" > 09/11/21, 21:50 </span>
-
Gerrit Code Review pushed patch set 13 for master to change 62956 <span data-processor="relativetime" data-value="2021-09-11T23:55:51+00:00" > 09/11/21, 23:55 </span>
-
Gerrit Code Review pushed patch set 14 for master to change 62956 <span data-processor="relativetime" data-value="2021-09-12T12:16:46+00:00" > 09/12/21, 12:16 </span>
-
Gerrit Code Review pushed patch set 15 for master to change 62956 <span data-processor="relativetime" data-value="2021-09-20T21:46:07+00:00" > 09/20/21, 21:46 </span>
-
Gerrit Code Review pushed patch set 16 for main to change 62956 <span data-processor="relativetime" data-value="2021-11-29T13:28:13+00:00" > 11/29/21, 13:28 </span>
-
Gerrit Code Review pushed patch set 17 for main to change 62956 <span data-processor="relativetime" data-value="2022-04-21T07:24:41+00:00" > 04/21/22, 07:24 </span>
-
Guido Schmechel changed Related to #101704 <span data-processor="relativetime" data-value="2023-08-18T07:02:57+00:00" > 08/18/23, 07:02 </span>
-
Sybille Peters changed category <span data-processor="relativetime" data-value="2023-08-18T07:41:27+00:00" > 08/18/23, 07:41 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 96538 <span data-processor="relativetime" data-value="2026-10-08T17:22:22+00:00" > 10/08/26, 17:22 </span>
-
Gerrit Code Review pushed patch set 2 for main to change 96538 <span data-processor="relativetime" data-value="2026-10-08T17:28:38+00:00" > 10/08/26, 17:28 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 96538 <span data-processor="relativetime" data-value="2026-10-16T09:48:08+00:00" > 10/16/26, 09:48 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 96538 <span data-processor="relativetime" data-value="2026-10-16T14:45:14+00:00" > 10/16/26, 14:45 </span>
-
Gerrit Code Review pushed patch set 5 for main to change 96538 <span data-processor="relativetime" data-value="2026-10-30T21:54:45+00:00" > 10/30/26, 21:54 </span>
Adding some performance numbers. ;)
Test Setup
I installed a TYPO3 10.3.0-dev with the Introduction package and created multiple redirects by adding the following code after Bootstrap::init in index.php and reloaded the page ONCE. After that I removed the code.
I did 6 sets with a different number of redirect records in the database (1k up to 400k).
Before each set, the typo3temp folder was removed to make sure all code caches are regenerated.
During each set, the page load time until redirect header was taken 6 times.
The first value was discarded because Cache had to regenerate, leaving us with 5 values for the page load time.
The time was measured using the following command, returning the time in seconds.
curl -w %{time_total} --url https://t3-contribution.ddev.site/test10Results
The full data is in the attached redirect-measure-time.ods file.
The table below shows the average response time until the redirect happens in miliseconds.
As you can see, the proposed implementation is a lot faster when many redirect records in the database.
With large TYPO3 websites, the current implementation may cause page load times up to 5 seconds, which is what we discovered in our real project.