Speeding up PostgreSQL query where data is between two dates
Posted
by Roger
on Stack Overflow
See other posts from Stack Overflow
or by Roger
Published on 2010-03-17T11:56:29Z
Indexed on
2010/03/17
12:01 UTC
Read the original article
Hit count: 282
I have a large table (> 50m rows) which has some data with an ID and timestamp.
I need to query the table to select all rows with a certain ID where the timestamp is between two dates, but it currently takes over 2 minutes on a high end machine. I'd really like to speed it up.
I have found this tip which recommends using a spatial index, but the example it gives is for IP addresses. However, the speed increase (436s to 3s) is impressive.
How can I use this with timestamps?
© Stack Overflow or respective owner