Skip to content

Instantly share code, notes, and snippets.

@mw44118
Created February 20, 2015 19:46
Show Gist options
  • Save mw44118/08f6fcf44eeef2c9ff2e to your computer and use it in GitHub Desktop.
Save mw44118/08f6fcf44eeef2c9ff2e to your computer and use it in GitHub Desktop.
slow query!
with current_config as
(
select *
from refractometer_config_history
where now()::timestamp without time zone <@ effective
)
select rmsh.sump_id, rr.refractometer_reading, current_config.*
from refractometer_readings rr
join refractometer_manifold_selection_history rmsh
on rr.inserted::timestamp without time zone <@ rmsh.effective
cross join current_config
where rr.inserted::timestamp without time zone <@ tsrange(
lower(rmsh.effective) + current_config.minutes_to_wait,
upper(rmsh.effective))
and sump_id = 3
order by inserted desc
limit 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment