或者具体的SQL语句
1)模拟表数据
create table t1 as select * from pg_class;
insert into t1 select * from t1;
select count(1) from t1 a;
2.执行SQL
select count(1) from t1 a,t1 b,t1 c;
3.查看执行计划
2025-07-26 23:43:28.925 CST,"postgres","postgres",26522,"[local]",6884f680.679a,13,"SELECT",2025-07-26 23:38:40 CST,2/16776,0,LOG,00000,"duration: 113114.265 ms plan:
Query Text: select count(1) from t1 a,t1 b,t1 c;
Aggregate (cost=9417597.40..9417597.41 rows=1 width=8) (actual time=113114.234..113114.238 rows=1 loops=1)
-> Nested Loop (cost=0.00..7849542.36 rows=627222016 width=0) (actual time=0.026..81300.633 rows=627222016 loops=1)
-> Nested Loop (cost=0.00..9230.46 rows=732736 width=0) (actual time=0.020..171.669 rows=732736 loops=1)
-> Seq Scan on t1 a (cost=0.00..34.56 rows=856 width=0) (actual time=0.013..2.589 rows=856 loops=1)
-> Materialize (cost=0.00..38.84 rows=856 width=0) (actual time=0.000..0.077 rows=856 loops=856)
-> Seq Scan on t1 b (cost=0.00..34.56 rows=856 width=0) (actual time=0.004..0.258 rows=856 loops=1)
-> Materialize (cost=0.00..38.84 rows=856 width=0) (actual time=0.000..0.042 rows=856 loops=732736)
-> Seq Scan on t1 c (cost=0.00..34.56 rows=856 width=0) (actual time=0.004..0.095 rows=856 loops=1)",,,,,,,,,"psql","client backend",,8235289341370696194
2025-07-26 23:43:28.925 CST,"postgres","postgres",26522,"[local]",6884f680.679a,14,"SELECT",2025-07-26 23:38:40 CST,2/0,0,LOG,00000,"duration: 113115.019 ms",,,,,,,,,"psql","client backend",,8235289341370696194
|