小编Sjo*_*jon的帖子

当 LIMIT 存在时,Postgres 12.1 使用仅索引向后扫描而不是索引

我有一个中等大小的“functionCalls”表(约 4M 行),由 2 列组成,input并且function(另一个表的两个 id):

\n\n
  Column  |  Type   | Collation | Nullable | Default \n----------+---------+-----------+----------+---------\n input    | integer |           | not null | \n function | integer |           | not null | \nIndexes:\n    "functionCall_pkey" PRIMARY KEY, btree (input, function) CLUSTER\n    "functionCallSearch" btree (function, input)\nForeign-key constraints:\n    "fkey1" FOREIGN KEY (function) REFERENCES function(id) ON UPDATE CASCADE ON DELETE CASCADE\n    "fkey2" FOREIGN KEY (input) REFERENCES input(id)\n\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想找到与某个函数匹配的所有行,这就是我添加索引的原因functionCallSearch。这是我的查询:

\n\n
  Column  |  Type   | Collation | …
Run Code Online (Sandbox Code Playgroud)

postgresql performance postgresql-performance

3
推荐指数
1
解决办法
2029
查看次数