Original query:

SELECT "main"."ID" "ID", "main"."name" "name", "ass"."name" "assigneduser_name", "main"."assigneduser" "assigneduser", "main"."url" "url", "main"."username" "username", "main"."password" "password", ("__tag1"."index" IS NOT NULL::int) "__tag1", (CASE WHEN "__extdata1"."value" ~ '^[ \t\v\r\n]*[+-]?[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?[ \t\v\r\n]*$' THEN "__extdata1"."value"::numeric END) "__extdata1", ("__tag2"."index" IS NOT NULL::int) "__tag2", (CASE WHEN "__extdata2"."value" ~ '^[ \t\v\r\n]*[+-]?[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?[ \t\v\r\n]*$' THEN "__extdata2"."value"::numeric END) "__extdata2", "__taggroup3"."name" "__taggroup3", "follow"."ID" "follow"
FROM (SELECT "main"."ID" "ID", "main"."name" "name", "main"."assigneduser" "assigneduser", "main"."url" "url", "main"."username" "username", "main"."password" "password"
FROM "links" "main"
WHERE ((("main"."ownergroup" IN (1, 2, 11, 12) OR "main"."owneruser" = 1005 OR ("main"."owneruser" IS NULL AND "main"."ownergroup" IS NULL) OR "main"."assigneduser" = 1005) AND "main"."visibility" = '0'))
ORDER BY "main"."name", "main"."ID"
LIMIT 100) "main"
LEFT JOIN LATERAL (SELECT "ID" FROM "follows" "follow" WHERE ("follow"."creator" = 1005 AND "follow"."entity" = 'links' AND "follow"."index" = "main"."ID")) "follow" ON TRUE
LEFT JOIN "users" "ass" ON "ass"."ID" = "main"."assigneduser"
LEFT JOIN LATERAL (SELECT "value" FROM "extdatavalues" "__extdata1" WHERE FALSE) "__extdata1" ON TRUE
LEFT JOIN LATERAL (SELECT "value" FROM "extdatavalues" "__extdata2" WHERE ("__extdata2"."field" = 3 AND "__extdata2"."index" = "main"."ID" AND "__extdata2"."value" <> '')) "__extdata2" ON TRUE
LEFT JOIN LATERAL (SELECT DISTINCT "index" FROM "tagsrels" "__tag1" WHERE "__tag1"."name" IN (40020, 40025, 40055, 40395, 40396, 40398, 40400, 40295, 40825)) "__tag1" ON TRUE
LEFT JOIN LATERAL "tagrels" "__tag2" ON TRUE
LEFT JOIN LATERAL (SELECT "__taggroup3"."index", STRING_AGG("tag"."name", ', ' ORDER BY "tag"."name") "name" FROM "tagrels" "__taggroup3" INNER JOIN "tagnames" "tag" ON "tag"."ID" = "__taggroup3"."name" WHERE "__taggroup3"."name" IN (40020, 40025, 40033, 40055, 40395, 40396, 40398, 40400, 40295, 40825) GROUP BY 1) "__taggroup3" ON TRUE
ORDER BY "main"."name", "main"."ID"