Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Help with a query

$
0
0
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?

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

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

Viewing all articles
Browse latest Browse all 13329

Trending Articles