This website works better with JavaScript.
Home
Explore
Help
Sign In
closed-social
/
mastodon
Watch
3
Star
0
Fork
2
Code
Issues
5
Pull Requests
0
Projects
0
Releases
3
Wiki
Activity
Browse Source
Fix slow distinct queries where grouped queries are faster (
#15287
)
About 2x speed-up on inboxes query
master
Eugen Rochko
3 years ago
committed by
GitHub
parent
a8c471fcc0
commit
48bef17cc9
No known key found for this signature in database
GPG Key ID:
4AEE18F83AFDEB23
4 changed files
with
4 additions
and
4 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+1
-1
app/controllers/accounts_controller.rb
+1
-1
app/controllers/admin/statuses_controller.rb
+1
-1
app/models/account.rb
+1
-1
app/models/form/account_batch.rb
+ 1
- 1
app/controllers/accounts_controller.rb
View File
@ -81,7 +81,7 @@ class AccountsController < ApplicationController
end
def
account_media_status_ids
@account
.
media_attachments
.
attached
.
reorder
(
nil
)
.
select
(
:status_id
)
.
distinct
@account
.
media_attachments
.
attached
.
reorder
(
nil
)
.
select
(
:status_id
)
.
group
(
:status_id
)
end
def
no_replies_scope
+ 1
- 1
app/controllers/admin/statuses_controller.rb
View File
@ -14,7 +14,7 @@ module Admin
@statuses
=
@account
.
statuses
.
where
(
visibility
:
[
:public
,
:unlisted
]
)
if
params
[
:media
]
account_media_status_ids
=
@account
.
media_attachments
.
attached
.
reorder
(
nil
)
.
select
(
:status_id
)
.
distinct
account_media_status_ids
=
@account
.
media_attachments
.
attached
.
reorder
(
nil
)
.
select
(
:status_id
)
.
group
(
:status_id
)
@statuses
.
merge!
(
Status
.
where
(
id
:
account_media_status_ids
)
)
end
+ 1
- 1
app/models/account.rb
View File
@ -443,7 +443,7 @@ class Account < ApplicationRecord
end
def
inboxes
urls
=
reorder
(
nil
)
.
where
(
protocol
:
:activitypub
)
.
pluck
(
Arel
.
sql
(
"
distinct
coalesce(nullif(accounts.shared_inbox_url, ''), accounts.inbox_url)
"
)
)
urls
=
reorder
(
nil
)
.
where
(
protocol
:
:activitypub
)
.
group
(
:preferred_inbox_url
)
.
pluck
(
Arel
.
sql
(
"
coalesce(nullif(accounts.shared_inbox_url, ''), accounts.inbox_url)
AS preferred_inbox_url
"
)
)
DeliveryFailureTracker
.
without_unavailable
(
urls
)
end
+ 1
- 1
app/models/form/account_batch.rb
View File
@ -51,7 +51,7 @@ class Form::AccountBatch
end
def
account_domains
accounts
.
pluck
(
Arel
.
sql
(
'distinct domain'
)
)
.
compact
accounts
.
group
(
:domain
)
.
pluck
(
:domain
)
.
compact
end
def
accounts
Write
Preview
Loading…
Cancel
Save