Best Way to Keep Page View Count in SQL Server

1.1k views Asked by At

I'll be keeping details of PageView counts for a specific table.

Table design is:

[IMAGE_ID] [int] IDENTITY(1,1) NOT NULL,
[IMAGE_PATH] [nvarchar](150) NOT NULL,
[CARTOON_ID] [int] NOT NULL,
[ADD_DATE] [datetime] NOT NULL,
[ADD_USER_ID] [int] NOT NULL,
[IMAGE_TEXT] [nvarchar](max) NULL

I'll be showing these images on each page and need the best way to keep the unique page view counts.

How would you do it?

Please remember that this table will have around 10000 images in short time and will a lot of activity. Updating this table on each request doesn't seem clever to me.

1

There are 1 answers

0
Pabuc On BEST ANSWER

I guess the best way is to keep a temp table with

IMAGE_ID
IP_ADDRESS
VISIT_DATE

and a view table that keeps

IMAGE_ID
COUNTER

And batch update the view table with the details of temp table and clear the content of it periodically.