I have table booking with such looking records:
id | from | to
------+---------------------+---------------------
101 | 2015-09-24 08:00:00 | 2015-09-24 09:30:00
2261 | 2015-09-24 09:00:00 | 2015-09-24 10:00:00
4061 | 2015-09-24 10:00:00 | 2015-09-24 10:30:00
204 | 2015-09-24 12:00:00 | 2015-09-24 13:30:00
2400 | 2015-09-24 13:30:00 | 2015-09-24 14:00:00
4224 | 2015-09-24 14:00:00 | 2015-09-24 14:30:00
309 | 2015-09-24 16:00:00 | 2015-09-24 17:30:00
2541 | 2015-09-24 17:00:00 | 2015-09-24 18:00:00
I am looking for optimal query to find anwser to question:
Is this possible to find a timeslot with duration x (ie. 30 minutes) in above records?
I have ideas to use postgres arrays or time ranges, but still looking for better ideas....
EDIT: I will provide 'fake' bookings as boundaries, but if you have ideas how to do it better, please write :)