Skip to content

Instantly share code, notes, and snippets.

@jdreaver
Created September 8, 2017 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdreaver/42ff8eab4aab45f9c445a885097d61aa to your computer and use it in GitHub Desktop.
Save jdreaver/42ff8eab4aab45f9c445a885097d61aa to your computer and use it in GitHub Desktop.
db-standby-1-prod [classroom_prod] # EXPLAIN ANALYZE SELECT "math_adaptive_assignment_sessions"."student_id", "math_adaptive_assignments"."domain_id", count (*) FROM "math_adaptive_assignments" INNER JOIN "math_adaptive_assignment_sessions" ON "math_adaptive_assignments"."id" = "math_adaptive_assignment_sessions"."assignment_id" INNER JOIN "knowledge_snapshots" ON "math_adaptive_assignment_sessions"."knowledge_snapshot_id" = "knowledge_snapshots"."id" INNER JOIN "answers" ON "knowledge_snapshots"."id" = "answers"."knowledge_snapshot_id" WHERE ("math_adaptive_assignment_sessions"."student_id" IN (7538860)) AND (("math_adaptive_assignment_sessions"."completed_at" >= '2017-09-08 08:00:00Z') AND (("math_adaptive_assignment_sessions"."completed_at" <= '2017-09-08 18:02:08.431692Z') AND ("answers"."correctness" >= 100.0))) GROUP BY "math_adaptive_assignment_sessions"."student_id", "math_adaptive_assignments"."domain_id";
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate (cost=273.74..273.86 rows=6 width=21) (actual time=0.025..0.025 rows=0 loops=1)
Group Key: math_adaptive_assignment_sessions.student_id, math_adaptive_assignments.domain_id
-> Sort (cost=273.74..273.75 rows=6 width=13) (actual time=0.023..0.023 rows=0 loops=1)
Sort Key: math_adaptive_assignments.domain_id
Sort Method: quicksort Memory: 25kB
-> Nested Loop (cost=2.00..273.66 rows=6 width=13) (actual time=0.019..0.019 rows=0 loops=1)
Join Filter: (math_adaptive_assignment_sessions.knowledge_snapshot_id = answers.knowledge_snapshot_id)
-> Nested Loop (cost=1.56..269.67 rows=1 width=25) (actual time=0.018..0.018 rows=0 loops=1)
-> Nested Loop (cost=1.14..261.21 rows=1 width=17) (actual time=0.018..0.018 rows=0 loops=1)
-> Index Scan using math_adaptive_assignment_sessions_student_id_idx on math_adaptive_assignment_sessions (cost=0.57..252.61 rows=1 width=12) (actual time=0.017..0.017 rows=0 loops=1)
Index Cond: (student_id = 7538860)
Filter: ((completed_at >= '2017-09-08 08:00:00+00'::timestamp with time zone) AND (completed_at <= '2017-09-08 18:02:08.431692+00'::timestamp with time zone))
Rows Removed by Filter: 3
-> Index Scan using math_adaptive_assignments_pkey on math_adaptive_assignments (cost=0.57..8.59 rows=1 width=13) (never executed)
Index Cond: (id = math_adaptive_assignment_sessions.assignment_id)
-> Index Only Scan using knowledge_snapshots_parent_pkey on knowledge_snapshots (cost=0.43..8.45 rows=1 width=8) (never executed)
Index Cond: (id = math_adaptive_assignment_sessions.knowledge_snapshot_id)
Heap Fetches: 0
-> Index Scan using answers_parent_knowledge_snapshot_id_idx on answers (cost=0.44..3.25 rows=59 width=4) (never executed)
Index Cond: (knowledge_snapshot_id = knowledge_snapshots.id)
Filter: (correctness >= '100'::double precision)
Planning time: 366.453 ms
Execution time: 0.079 ms
(23 rows)
Time: 457.075 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment