考试科目:PGCA-E-090
考试题数:40 道单项选择题、10 道多项选择题(每题 2 分)
通过分数:60%
考试时间:60min
本文为云贝教育刘峰(微信:yunbee_DBA)原创,请尊重知识产权,转发请注明出处,不接受任何抄袭、演绎和未经注明出处的转载。
在PostgresSQL中,表和索引的行数、块数等统计信息记录在哪个系统表中?
A. pg_statistic
B. pg_proc
C. pg_index
D. pg_class
参考答案:D
解析:
以一条SQL的查询为例
testdb=# select count(1) from s1.t1;
count
-------
415
(1 row)
testdb=# explain select count(1) from s1.t1;
QUERY PLAN
-----------------------------------------------------------
Aggregate (cost=16.19..16.20 rows=1 width=8)
-> Seq Scan on t1 (cost=0.00..15.15 rows=415 width=0)
(2 rows) 从上面的结果可以看到,t1表的扫描行数是415 ,真实结果也是415 ,那这个415从哪读取的?
关于pg_class视图解析:https://www.postgresql.org/docs/16/catalog-pg-class.html
查看pg_classs
select pc.oid,relname,pn.nspname,reltuples,pu.usename from pg_class pc,pg_userpu,pg_namespace pn where relname='t1' and usename='test' and pu.usesysid=pc.relowner and pn.oid=pc.relnamespace;
oid | relname | nspname | reltuples | usename
-------+---------+---------+-----------+---------
24594 | t1 | s1 | 415 | test可以看到t1表属于用户test,模式s1
最后修改时间:2023-11-23 10:41:35
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




