Documented performance issue when sorting by visits or short URLs count

This commit is contained in:
Alejandro Celaya 2022-01-23 10:48:38 +01:00
parent 8adb6596fb
commit cdb18a5baf
3 changed files with 5 additions and 2 deletions

View file

@ -45,7 +45,7 @@
{
"name": "orderBy",
"in": "query",
"description": "To determine how to order the results.",
"description": "To determine how to order the results.<br /><br />**Important!** Ordering by `shortUrlsCount` or `visitsCount` has a [known performance issue](https://github.com/shlinkio/shlink/issues/1346) which makes loading a subset of the list take as much as loading the whole list.<br />If you plan to order by any of these fields, it's worth loading the whole list with no pagination.",
"required": false,
"schema": {
"type": "string",

View file

@ -12,6 +12,9 @@ final class Ordering
{
}
/**
* @param array{string|null, string|null} $props
*/
public static function fromTuple(array $props): self
{
[$field, $dir] = $props;

View file

@ -84,7 +84,7 @@ class TagRepository extends EntitySpecificationRepository implements TagReposito
->groupBy('t.id_0', 't.name_1');
// Apply API key role conditions to the native query too, as they will affect the amounts on the aggregates
$apiKey?->mapRoles(fn (string $roleName, array $meta) => match ($roleName) {
$apiKey?->mapRoles(static fn (string $roleName, array $meta) => match ($roleName) {
Role::DOMAIN_SPECIFIC => $nativeQb->andWhere(
$nativeQb->expr()->eq('s.domain_id', $conn->quote(Role::domainIdFromMeta($meta))),
),