Skip to content

Instantly share code, notes, and snippets.

@sprite2005
Created February 20, 2020 19:50
Show Gist options
  • Save sprite2005/f622079be63be1ecade2d45643f79c39 to your computer and use it in GitHub Desktop.
Save sprite2005/f622079be63be1ecade2d45643f79c39 to your computer and use it in GitHub Desktop.
Started GET "/api/users/search" for ::1 at 2020-02-20 14:48:18 -0500
Processing by Api::UsersController#search as */*
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", "8b89fba2-9f4a-4abf-ba36-159edc9b9253"], ["LIMIT", 1]]
↳ app/commands/authorize_api_request.rb:17:in `user'
User Load (0.8ms) SELECT "users".* FROM "users" WHERE (NOT EXISTS (SELECT * FROM swipes WHERE sender_id = '8b89fba2-9f4a-4abf-ba36-159edc9b9253' AND receiver_id = users.id)) AND "users"."id" != $1 LIMIT $2 [["id", "8b89fba2-9f4a-4abf-ba36-159edc9b9253"], ["LIMIT", 10]]
↳ app/models/user.rb:45:in `search'
Photo Load (0.6ms) SELECT "photos".* FROM "photos" WHERE "photos"."user_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) [["user_id", "a76b7a81-8ec4-41d4-8ad1-1082a8d42254"], ["user_id", "7e9de44d-b698-4f55-b815-5a1d4cc87770"], ["user_id", "9cdc8e1a-420c-440b-9422-3c1780098ca9"], ["user_id", "ed264c9d-fce5-4c0a-8c07-34b36ee63432"], ["user_id", "9915fb47-74e6-459e-8e09-b08da58f637c"], ["user_id", "bbff317e-0a3f-40a1-9e32-16345591e3df"], ["user_id", "6b8c037a-91a3-4aa6-8c80-ed61cbf6adef"], ["user_id", "63d8a814-aa5d-4b85-86c7-ee2db26665f2"], ["user_id", "d261f4e5-3b90-4556-ac62-dd3a96ddc18d"], ["user_id", "90b4f1c6-1454-4cec-bc87-b409e74ccaeb"]]
↳ app/models/user.rb:45:in `search'
EXPLAIN for: SELECT "users".* FROM "users" WHERE (NOT EXISTS (SELECT * FROM swipes WHERE sender_id = '8b89fba2-9f4a-4abf-ba36-159edc9b9253' AND receiver_id = users.id)) AND "users"."id" != $1 LIMIT $2 [["id", "8b89fba2-9f4a-4abf-ba36-159edc9b9253"], ["LIMIT", 10]]
QUERY PLAN
-------------------------------------------------------------------------------------------------------------
Limit (cost=0.29..3.87 rows=10 width=241)
-> Nested Loop Anti Join (cost=0.29..106.64 rows=297 width=241)
-> Seq Scan on users (cost=0.00..13.75 rows=299 width=241)
Filter: (id <> '8b89fba2-9f4a-4abf-ba36-159edc9b9253'::uuid)
-> Index Scan using index_swipes_on_receiver_id on swipes (cost=0.29..487.80 rows=23895 width=16)
Index Cond: (receiver_id = users.id)
Filter: (sender_id = '8b89fba2-9f4a-4abf-ba36-159edc9b9253'::uuid)
(7 rows)
EXPLAIN for: SELECT "photos".* FROM "photos" WHERE "photos"."user_id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) [["user_id", "a76b7a81-8ec4-41d4-8ad1-1082a8d42254"], ["user_id", "7e9de44d-b698-4f55-b815-5a1d4cc87770"], ["user_id", "9cdc8e1a-420c-440b-9422-3c1780098ca9"], ["user_id", "ed264c9d-fce5-4c0a-8c07-34b36ee63432"], ["user_id", "9915fb47-74e6-459e-8e09-b08da58f637c"], ["user_id", "bbff317e-0a3f-40a1-9e32-16345591e3df"], ["user_id", "6b8c037a-91a3-4aa6-8c80-ed61cbf6adef"], ["user_id", "63d8a814-aa5d-4b85-86c7-ee2db26665f2"], ["user_id", "d261f4e5-3b90-4556-ac62-dd3a96ddc18d"], ["user_id", "90b4f1c6-1454-4cec-bc87-b409e74ccaeb"]]
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Seq Scan on photos (cost=0.00..8.40 rows=42 width=187)
Filter: (user_id = ANY ('{a76b7a81-8ec4-41d4-8ad1-1082a8d42254,7e9de44d-b698-4f55-b815-5a1d4cc87770,9cdc8e1a-420c-440b-9422-3c1780098ca9,ed264c9d-fce5-4c0a-8c07-34b36ee63432,9915fb47-74e6-459e-8e09-b08da58f637c,bbff317e-0a3f-40a1-9e32-16345591e3df,6b8c037a-91a3-4aa6-8c80-ed61cbf6adef,63d8a814-aa5d-4b85-86c7-ee2db26665f2,d261f4e5-3b90-4556-ac62-dd3a96ddc18d,90b4f1c6-1454-4cec-bc87-b409e74ccaeb}'::uuid[]))
(2 rows)
Rendering api/users/search.json.jbuilder
Rendered api/users/search.json.jbuilder (Duration: 32.1ms | Allocations: 12788)
Completed 200 OK in 43ms (Views: 32.7ms | ActiveRecord: 3.0ms | Allocations: 16766)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment