http://www.depesz.com/index.php/2007/11/21/find-overlapping-time-ranges/

how to use “search by timerange” postgres and use index