[#3213] Experimental / debug feature: database: [improved_hashtag_timeline: :preselect_hashtag_ids]
.
This commit is contained in:
parent
b981edad8a
commit
998437d4a4
|
@ -787,6 +787,28 @@ defp restrict_hashtag_any(_query, %{tag: _tag, skip_preload: true}) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp restrict_hashtag_any(query, %{tag: [_ | _] = tags}) do
|
defp restrict_hashtag_any(query, %{tag: [_ | _] = tags}) do
|
||||||
|
# TODO: refactor: debug / experimental feature
|
||||||
|
if Config.get([:database, :improved_hashtag_timeline]) == :preselect_hashtag_ids do
|
||||||
|
hashtag_ids =
|
||||||
|
from(ht in Pleroma.Hashtag,
|
||||||
|
where: fragment("name = ANY(?::citext[])", ^tags),
|
||||||
|
select: ht.id
|
||||||
|
)
|
||||||
|
|> Repo.all()
|
||||||
|
|
||||||
|
from(
|
||||||
|
[_activity, object] in query,
|
||||||
|
where:
|
||||||
|
fragment(
|
||||||
|
"""
|
||||||
|
EXISTS (
|
||||||
|
SELECT 1 FROM hashtags_objects WHERE hashtag_id = ANY(?) AND object_id = ? LIMIT 1)
|
||||||
|
""",
|
||||||
|
^hashtag_ids,
|
||||||
|
object.id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else
|
||||||
from(
|
from(
|
||||||
[_activity, object] in query,
|
[_activity, object] in query,
|
||||||
where:
|
where:
|
||||||
|
@ -801,6 +823,7 @@ defp restrict_hashtag_any(query, %{tag: [_ | _] = tags}) do
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp restrict_hashtag_any(query, %{tag: tag}) when is_binary(tag) do
|
defp restrict_hashtag_any(query, %{tag: tag}) when is_binary(tag) do
|
||||||
restrict_hashtag_any(query, %{tag: [tag]})
|
restrict_hashtag_any(query, %{tag: [tag]})
|
||||||
|
|
Loading…
Reference in a new issue