Evus
Evus

Reputation: 400

SQL Design, Duplicate data for speed?

When I want to track user logins, I have separate table for logins. Ie.

uid, login_time

and table for users

id, username, password

After millions of logins, is it good to have separate column for login time in user table or is it useless. And what is bestway to query users and their last login.

Upvotes: 0

Views: 102

Answers (1)

RT72
RT72

Reputation: 191

If you want to have the ability to both audit all logins and query a users last login then IMHO writing to a last_login_time column on the user table at the same time as writing your login audit record would suffice. Then a query for most recent login is going to be more efficient than trawling through the audit table

Upvotes: 1

Related Questions