简体   繁体   English

为什么这个索引扫描这么慢?

[英]Why is this Index Scan so slow?

From what I can see, the index is not entirely loaded up in memory, and that's what causing it to be slow?从我所见,索引并没有完全加载到 memory 中,这就是导致它变慢的原因? Am I correct?我对么?

obs: I changed the "Output" section a little bit for privacy concerns obs:出于隐私考虑,我稍微更改了“输出”部分

->  Index Scan using idx_customers_orders on public.customers  (cost=0.57..20.28 rows=1 width=13) (actual time=1.757..1.774 rows=1 loops=46257)
                           Output: customers.id, customers.created_at, customers.created_by ,customers.registration ,customers.name ,customers.description ,customers.address ,customers.location ,customers.code
                           Index Cond: (customers.i_order = orders.i_order)
                           Filter: ((NOT customers.deleted) AND (customers.i_databases = (current_setting('db.tenant'::text))::integer))
                           Rows Removed by Filter: 0
                           Buffers: shared hit=164654 read=68033
                           I/O Timings: read=80791.000

The index scan is fast (1.774 milliseconds on average).索引扫描很快(平均 1.774 毫秒)。 The execution is so slow because the index scan is executed 46257 times.执行速度很慢,因为索引扫描执行了 46257 次。 Slightly over 1 millisecond for reading an 8kB-block from disk isn't so bad.从磁盘读取一个 8kB 块的时间略多于 1 毫秒并不是那么糟糕。

Most likely, the index scan is on the inner side of a nested loop join.最有可能的是,索引扫描位于嵌套循环连接的内侧。 Perhaps a different join strategy would be better;也许不同的加入策略会更好; since you don't show the execution plan, we cannot tell.由于您没有显示执行计划,我们无法判断。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM