tayabe.blogg.se

Postgresql else if
Postgresql else if











postgresql else if postgresql else if

PostgreSQL realizes that it isn't a correlated subquery and it's a just a reduces it to a literal (essentially). Here we can see that the Aggregate is looped through loops=1 time. However, if we set it to something like CASE WHEN x>20 THEN (SELECT sum(x) FROM foo you'll see a lot more Seq Scan on foo (cost=2.26.4.51 rows=100 width=4) (actual time=0.020.0.095 rows=100 loops=1)

postgresql else if

You can see that with (never executed) on the Aggregate line. The plan will show that the case is accompanied for, but never executed. (CASE WHEN x>200 THEN (SELECT sum(x) FROM foo) END) SELECT x FROM generate_series(1,100) AS x Īnd, now let's run a basic query with subquery, outside of the possible range of execution. You didn't provide any sample data, so let's create some. There are three important parts to reading query plans here,













Postgresql else if