Given an arbitrary pair of origin & destination, how do I design a system that can effectively query all paths that cross the pair from a GPS dataset? Data
I have a data set containing more than 8000 taxi drivers' GPS information, including time stamp, longitude, latitude, speed.  

Objective
I intend to design a system which can query all taxi trajectories that cross any given pair of origin and destination and output these trajectories effectively.  

Question
The queried origin-destination pair is random, lengths of trajectories (number of the pairs of longitude and latitude) do vary, not very structured, how could I achieve the objective?
A DB with spatial capabilities built-in should be able to do that. One option would be PostGIS. Check out this link for example queries using it.