SQL query time optimization [closed]

1

I have a database that stores precipitations marked by multiple sensors at certain dates and times over a year. I am making a query, to fetch all records marked by a single sensor, with the following SELECT p.latitude, p.longitude, h.precipitacaoh, h.datah, h.horah FROM pontos AS p, historico AS h WHERE p.gid = 913 statement and the time spent is around 9.36 minutes. But there are 1517 sensors and I need to recover all the records of each one of them, which would total more or less 9 days searching all these records. Does anyone know a way to shorten this query time?

    
asked by anonymous 22.11.2016 / 13:57

0 answers