|
|
|
|
|
by anarazel
2164 days ago
|
|
The largest part of the time executing the above query isn't inside the function, so this isn't that a material comparison. The reason for that is that SRFs in FROM to be materialized into a tuplestore, which isn't free: postgres[607045][1]=# SELECT count(*) FROM generate_series(1, 10000000);
┌──────────┐
│ count │
├──────────┤
│ 10000000 │
└──────────┘
(1 row)
Time: 1249.224 ms (00:01.249)
postgres[607045][1]=# SELECT count(*) FROM (SELECT generate_series(1, 10000000)) s;
┌──────────┐
│ count │
├──────────┤
│ 10000000 │
└──────────┘
(1 row)
Time: 460.206 ms
For mostly historical reasons SRFs in the target list can use the non-materializing SRF query protocol, but SRFs in the FROM list can't.Any chance you could show the timings for the pgx version of the second query? |
|
edit: PS, thanks for the idea of putting what I assume is the backend pid in psql's prompt. I need to go figure out how to do that right now!
edit edit: hmm, I guess that's not the PID.