I have a table with just one column: userid.
When a user accesses a certain page, his userid is being inserted to the table. Userids are unique, so there shouldn't be two of the same userids in that table.
I'm considering two designs:
- Making the column unique and using
INSERT
commands every time a user accesses that page. - Checking if the user is already recorded in the table by
SELECT
ing from the table, thenINSERT
ing if no record is found.
Which one is faster?
See Question&Answers more detail:os