Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.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
PostgreSQL:select null vs false的性能_Sql_Database_Performance_Postgresql - Fatal编程技术网

PostgreSQL:select null vs false的性能

PostgreSQL:select null vs false的性能,sql,database,performance,postgresql,Sql,Database,Performance,Postgresql,在具有大表(>10M行)的PostgreSQL(v9.4)中,这两个查询的性能(速度)有什么不同吗 选择bigint列中值为null的所有条目 选择boolean列中值为false的所有条目 另外,如果对varchar列执行查询编号1,会有什么不同吗 谢谢 否——理论上,您的任何选项本身都不会产生性能差异。你只是在比较数据。区别在于Where子句中指定的任何列是否被索引 如果您对所有其他bigint值都不感兴趣,我会添加部分索引在mytable(mybigint)上创建索引nonnullinde

在具有大表(>10M行)的PostgreSQL(v9.4)中,这两个查询的性能(速度)有什么不同吗

  • 选择
    bigint
    列中值为
    null
    的所有条目
  • 选择
    boolean
    列中值为
    false
    的所有条目
  • 另外,如果对
    varchar
    列执行查询编号1,会有什么不同吗


    谢谢

    否——理论上,您的任何选项本身都不会产生性能差异。你只是在比较数据。区别在于Where子句中指定的任何列是否被索引

    如果您对所有其他bigint值都不感兴趣,我会添加部分索引<代码>在mytable(mybigint)上创建索引nonnullindex,其中mybigint不为null严格来说,这不是真的:空值作为位图存储在元组头中,并在进行任何其他比较之前进行检查,因此从理论上讲,空值检查比相等比较要省力。实际上,当然,差别可以忽略不计,因为你最终会阅读相同数量的页面。我明白了。谢谢大家的贡献!最后一点需要澄清@Russ、mlt和Dmitri:布尔列和bigint列的b树索引的大小和索引开销有什么不同吗?