Re: effect on planner of turning a subquery to a table, sql function returning table

2024-04-12 Thread Thierry Henrio
ff). So I have options : O1) set jit=0, O2) temp table, O3) rework schema design (a variation on O2). Thanks! On Fri, Apr 12, 2024 at 1:40 PM David Rowley wrote: > On Fri, 12 Apr 2024 at 23:27, Thierry Henrio > wrote: > > JIT: > >Functions: 36 > >Options: Inli

Re: effect on planner of turning a subquery to a table, sql function returning table

2024-04-12 Thread Thierry Henrio
Thanks David! Here are the plans with (ANALYZE, BUFFERS), and track_io_timing ON: (A) GroupAggregate (cost=401037.82..503755.82 rows=1467400 width=124) (actual time=416.851..426.534 rows=4670 loops=1) Group Key: t.device_id, t.date, t.start_time, t.end_time, (timerange(((t_1.value ->> 0))::

effect on planner of turning a subquery to a table, sql function returning table

2024-04-12 Thread Thierry Henrio
Hi there, I work on a booking system. Below is a query showing reservations of devices that overlaps a campaign. A campaign has duration and time intervals by day of week. Here is a query (A): select device_id, t.date, timerange(t.start_time, t.end_time) * g.times as times from device_time

Re: plan for function returning table combined with condition

2022-07-21 Thread Thierry Henrio
On Wed, Jul 20, 2022 at 8:39 PM Tom Lane wrote: > You want this SQL function to be inlined, but it isn't being. > I think the reason is that (by default) it's VOLATILE, and > inline_set_returning_function doesn't like that: > > * Forget it if the function is not SQL-language or has other > s

plan for function returning table combined with condition

2022-07-20 Thread Thierry Henrio
Hello, I have a table with a jsonb row, opening_times, that I need to expand for later processing. jsonb is an object, like so {"1": [["06:00:00", "23:59:59"]], ...}. select id, name, day::int, (value -> 0 ->> 0)::time as startt, (value -> 0 ->> 1)::time as endt from ( select s.id, s.name, j.*