In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
CREATE INDEX performance_points_idx_date ON "performance_points" ("date");
CREATE INDEX performance_points_idx_id_user_id ON "performance_points" ("id","user_id");
CREATE INDEX team_memberships_idx_team_id_user_id ON "team_memberships" ("team_id","user_id");
CREATE INDEX users_idx_id ON "users" ("id");
SELECT
u.id,
u.slug,
SUM(pp.points) AS total
FROM
users u
JOIN
performance_points pp
ON pp.user_id = u.id
JOIN
team_memberships tm
ON tm.team_id = pp.team_id
AND tm.user_id = pp.user_id
WHERE
(
pp.date > '2015-08-02 13:57:14.042221'
)
GROUP BY
pp.id,
pp.user_id
ORDER BY
total DESC LIMIT 50