Event Timeline
Comment Actions
as @olasd pointed out, changing P242$19 from language sql to language sql stable makes the behavior of the function match the inline query.
And we can make it stable because it has no side-effect.
source:
- doc: https://www.postgresql.org/docs/current/static/xfunc-volatility.html
- @olasd in irc discussion:
12:03:49 ardumont | olasd: did you already have an sql function hanging while the equivalent inline query (same input, same dataset) is working fine? 12:04:36 olasd | what's in the function? 12:05:12 ardumont | select with join on 2 tables with filtering 12:05:23 ardumont | the hanging occurs on period when there is no data 12:05:29 ardumont | that match 12:07:51 ardumont | https://forge.softwareheritage.org/P242 12:10:09 olasd | try marking the function as stable in the declaration 12:10:40 olasd | volatile functions turn off a bunch of optimizer stuff 12:10:47 ardumont | ohhh 12:11:32 olasd | (it'll also allow the optimizer to inline the function call) 12:11:38 ardumont | you rock 12:11:39 ardumont | ;) 12:12:06 olasd | (most "read only" functions should be marked as stable) 12:12:30 ardumont | ok 12:13:01 olasd | (which tells the optimizer that their output is constant in the same transaction, and that (if the function is plain sql) it can inline the queries)
Related T986