count()和explain查询返回的列数不同

时间:2018-05-04 08:11:58

标签: sql database postgresql

Explain on the same table

在这里,你可以看到它在表格中显示了超过一百万行,但实际上它只有6行。这种方式有4个锁。 很多次我会收到一条错误,说“发送到后端时发生了I / O错误”。这是由于数据库连接超时或关闭,这也是由于表中的大量数据。

Count on the table's rows

注意:在此表上执行选择/更新/删除可能需要30s-10m。

1 个答案:

答案 0 :(得分:2)

解释无分析显示您从统计数据中估算 - 使用explain analyze确切计划和准确计数。

https://www.postgresql.org/docs/current/static/sql-explain.html

  

分析

     

执行命令并显示实际运行时间等   统计。此参数默认为FALSE。

https://www.postgresql.org/docs/current/static/using-explain.html

相关问题