我使用以下查询查询表中所有记录的计数: -
groups=# select count(*) from auth_user;
count
---------
1000000
(1 row)
以下是上表的架构: -
groups=# \d auth_user;
Table "public.auth_user"
Column | Type | Modifiers
--------------+--------------------------+--------------------------------------------------------
id | integer | not null default nextval('auth_user_id_seq'::regclass)
password | character varying(128) | not null
last_login | timestamp with time zone |
is_superuser | boolean | not null
username | character varying(150) | not null
first_name | character varying(30) | not null
last_name | character varying(150) | not null
email | character varying(254) | not null
is_staff | boolean | not null
is_active | boolean | not null
date_joined | timestamp with time zone | not null
Indexes:
"auth_user_pkey" PRIMARY KEY, btree (id)
"auth_user_username_key" UNIQUE CONSTRAINT, btree (username)
"auth_user_username_6821ab7c_like" btree (username varchar_pattern_ops)
Referenced by:
TABLE "auth_user_groups" CONSTRAINT "auth_user_groups_user_id_6a12ed8b_fk_auth_user_id" FOREIGN KEY (user_id) REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED
TABLE "auth_user_user_permissions" CONSTRAINT "auth_user_user_permissions_user_id_a95ead1b_fk_auth_user_id" FOREIGN KEY (user_id) REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED
TABLE "django_admin_log" CONSTRAINT "django_admin_log_user_id_c564eba6_fk" FOREIGN KEY (user_id) REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED
TABLE "groups_membership" CONSTRAINT "groups_membership_approved_by_id_e04d19ff_fk_auth_user_id" FOREIGN KEY (approved_by_id) REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED
TABLE "groups_membership" CONSTRAINT "groups_membership_member_id_241678d9_fk_auth_user_id" FOREIGN KEY (member_id) REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED
TABLE "groups_membershipinvite" CONSTRAINT "groups_membershipinvite_receiver_id_f8261ed4_fk_auth_user_id" FOREIGN KEY (receiver_id) REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED
TABLE "groups_membershipinvite" CONSTRAINT "groups_membershipinvite_sender_id_09bda548_fk_auth_user_id" FOREIGN KEY (sender_id) REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED
TABLE "groups_membershiprequest" CONSTRAINT "groups_membershiprequest_requestor_id_23767f01_fk_auth_user_id" FOREIGN KEY (requestor_id) REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED
现在,当我使用explain来分析上面查询的执行计划时,显示的记录计数显示额外的80行
groups=# explain analyze select count(*) from auth_user;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=20835.00..20835.01 rows=1 width=0) (actual time=830.661..830.661 rows=1 loops=1)
-> Seq Scan on auth_user (cost=0.00..18334.80 rows=1000080 width=0) (actual time=41.071..779.325 rows=1000000 loops=1)
Planning time: 0.052 ms
Execution time: 830.691 ms
(4 rows)
我的问题是,这80行来自哪里?我错过了什么吗?
提前致谢。