Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何提高计数查询的速度?_Sql_Postgresql - Fatal编程技术网

Sql 如何提高计数查询的速度?

Sql 如何提高计数查询的速度?,sql,postgresql,Sql,Postgresql,当我运行count查询时,在users表中有大约10087250条记录 SELECT COUNT(1) FROM users; 大约需要13到18秒。如何减少查询时间。无论如何,计数可能会很慢。不过,如果它能满足您的需要,您可以进行估算@一匹没有名字的马:对(删除我的评论)你的服务器版本是什么?它的postgres 9.6

当我运行count查询时,在users表中有大约10087250条记录

SELECT COUNT(1) FROM users;

大约需要13到18秒。如何减少查询时间。

无论如何,计数可能会很慢。不过,如果它能满足您的需要,您可以进行估算@一匹没有名字的马:对(删除我的评论)你的服务器版本是什么?它的postgres 9.6