You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there's some missing indexes that could really improve performance on our queries. There's one missing from friendships, but there are probably others.
How to test indexes, even without enough data.
In the database.yml, add the following to the appropriate environment (development/test).
variables: {
enable_seqscan: 'off'
}
Then restart the rails server, and all future requests will attempt to use any index available before doing a seq scan.
Indexes Needed
Add index for [buddy_id, friend_id] on friendship
Query attempted in profile.friends
Makes a nested loop - check if it's cleaner after indexes?
test_query = Profile.where(Profile.arel_table[:id].in(Arel.sql(<<-SQL.squish, profile_id: id)))
SELECT CASE
WHEN friendships.friend_id = :profile_id THEN friendships.buddy_id
WHEN friendships.buddy_id = :profile_id THEN friendships.friend_id
END AS profile_id
FROM friendships
WHERE (friend_id = :profile_id
OR buddy_id = :profile_id)
AND status = 0
SQL
The text was updated successfully, but these errors were encountered:
I think there's some missing indexes that could really improve performance on our queries. There's one missing from friendships, but there are probably others.
How to test indexes, even without enough data.
In the database.yml, add the following to the appropriate environment (development/test).
Then restart the rails server, and all future requests will attempt to use any index available before doing a seq scan.
Indexes Needed
Query attempted in profile.friends
Makes a nested loop - check if it's cleaner after indexes?
The text was updated successfully, but these errors were encountered: