Please explain, slow vs fast flux query

please explain the difference in time spent on this flux query
It does the same thing, but query 2 takes 50 times more time)

example 1 measures 0,019s for output
example 2 measures 1s.
time is measured at terminal

query1

maxes = from(bucket: "Metering/autogen")
  |> range(start: 2022-10-01T00:00:00Z, stop: 2022-10-31T00:00:00Z)
  |> filter(fn: (r) => r["_measurement"] == "photoPV")
  |> filter(fn: (r) => r["_field"] == "Total")
  |> aggregateWindow(every: 1d, fn: max, createEmpty: false)

mins = from(bucket: "Metering/autogen")
  |> range(start: 2022-10-01T00:00:00Z, stop: 2022-10-31T00:00:00Z)
  |> filter(fn: (r) => r["_measurement"] == "photoPV")
  |> filter(fn: (r) => r["_field"] == "Total")
  |> aggregateWindow(every: 1d, fn: min, createEmpty: false)

join(
  tables: {min:mins, max:maxes},
  on: ["_time"]
)
  |> map(fn: (r) => ({ r with _value: r._value_max - r._value_min}))
  |> keep(columns: ["_time","_value"])
  |> rename(columns: {_value: "sunpower"})

query 2

query_pv = from(bucket: "Metering/autogen")
  |> range(start: 2022-10-01T00:00:00Z, stop: 2022-10-31T00:00:00Z)
  |> filter(fn: (r) => r["_measurement"] == "photoPV")
  |> filter(fn: (r) => r["_field"] == "Total")

mins_pv = query_pv
  |> aggregateWindow(every: 1d, fn: min, createEmpty: false)
maxs_pv = query_pv
  |> aggregateWindow(every: 1d, fn: max, createEmpty: false)

join(
  tables: {min_pv:mins_pv, max_pv:maxs_pv},
  on: ["_time"]
)
  |> map(fn: (r) => ({ r with _value: r._value_max_pv - r._value_min_pv}))
  |> keep(columns: ["_time","_value"])
  |> rename(columns: {_value: "sunpower"})