0
我知道這是種一個尷尬的問題..但我不明白是什麼EXPLAIN
解釋..理解的Rails/PG解釋
我查詢User.last
,花了0.5秒以上 這可能是最簡單的的查詢,但似乎解釋有麻煩解釋它..
我不明白什麼後QUERY PLAN
什麼寬度?是什麼成本?它是如何解釋在查詢了多長時間?
[40] pry(main)> User.last
User Load (671.0ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
EXPLAIN (39.0ms) EXPLAIN SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
EXPLAIN for: SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
QUERY PLAN
--------------------------------------------------------------------
Limit (cost=1.08..1.08 rows=1 width=2861)
-> Sort (cost=1.08..1.09 rows=5 width=2861)
Sort Key: id
-> Seq Scan on users (cost=0.00..1.05 rows=5 width=2861)
(4 rows)