postgresql 为什么这么慢

a002269 2018-01-31 03:39:56
select count(*) from t_table1 as t1 where (或 not) exists (select null from t_table2 as t2 where t2.user_id = t1.user_id)

同样的条件,同样2500万条记录。

为什么mssql,1秒就出结果了
而 postgresql 要 120 才出结果?
...全文
585 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
a002269 2018-01-31
  • 打赏
  • 举报
回复
他还真不走索引,不过修改了配置文件,让他走索引了,就算这样还是要12秒。。。mssql随便怎么搞,基本上一两秒也就出结果了。什么 not in not exists 什么都不用考虑。
a002269 2018-01-31
  • 打赏
  • 举报
回复
Limit (cost=1143.73..1349.35 rows=1000 width=649) -> Hash Join (cost=1143.73..4961995.65 rows=24126796 width=649) Hash Cond: (t1.user_id = t2.user_id) -> Seq Scan on t_table1 t1 (cost=0.00..4656257.96 rows=24126796 width=649) -> Hash (cost=752.77..752.77 rows=31277 width=8) -> Seq Scan on t_table t2 (cost=0.00..752.77 rows=31277 width=8) 他不走索引么?

951

社区成员

发帖
与我相关
我的任务
社区描述
PostgreSQL相关内容讨论
sql数据库数据库架构 技术论坛(原bbs)
社区管理员
  • PostgreSQL社区
  • yang_z_1
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧