Greater than or equal to ALL() and equal to MAX() speed

后端 未结 4 1498
春和景丽
春和景丽 2021-01-16 03:08

I have a relation in PostgreSQL named product which contains 2 fields: id and quantity, and I want to find the id of the

4条回答
  •  梦谈多话
    2021-01-16 03:31

    I tried your methods in postgres (test table distributed by id). That first method ran much slower for me. Here were my comparison results:

    Method 1 above: 3.1 seconds

    Method 2 above: 0.13 seconds

    Method 1 was at least 10 times slower in repeated efforts. I think your method 2 is the better option, as the sub-query likely runs much faster than the sub-query in the other option.

提交回复
热议问题