I'm trying to query a table with over 2,000,000 rows, and the query I wrote is taking about 30 seconds to complete. I'm wondering if there's any way to speed it up?
I have a table with all the actions logged. I'm looking for the number of people who logged in and registered within the last 15 days.
TableActions
ActionID = INT PK
ActionUserID = INT FK
ActionStatus = Varchar
ActionTime = DateTime
Code:
select current timestamp, count(a.actionuserid)
from actions a
join actions b
on a.actionuserid = b.actionuserid
where a.actionstatus='Login' and b.actionstatus='Registered' and a.actiontime between current timestamp - 15 days and current timestamp
TableActions
ActionID = INT PK
ActionUserID = INT FK
ActionStatus = Varchar
ActionTime = DateTime