Page 1 of 1

Recently viewed products - how do u do it?

Posted: Tue May 17, 2011 5:06 am
by simonmlewis
Hi

I created a db table to store up to 5 products a person has visited.
However, because this particular web site gets a vast amount of viewings, the db table gather over 240,000 entry rows.

It stores them by their IP Address. So each time a product page is loaded, it looks for their IPs, and then deletes the oldest one and adds the latest. But looking for 5 IPs in 240,000+ rows is very time consuming.

And then on each page it looks for those 5 IPs and shows them on a page to show those 5 products.

It slowed the web site down BIG TIME.

Is there a better way to do this?

Re: Recently viewed products - how do u do it?

Posted: Tue May 17, 2011 5:13 am
by zyntrax
Have you tried changing so that it creates 1 row per product and store all ips on the same row?

Re: Recently viewed products - how do u do it?

Posted: Tue May 17, 2011 5:53 am
by Kastor
Store them in cookie on client side

Re: Recently viewed products - how do u do it?

Posted: Tue May 17, 2011 10:26 am
by flying_circus
simonmlewis wrote:Is there a better way to do this?
We would have to see some of your code to give you good advice but you should be able to pull all that information, rather quickly, with a single query. A better way to index the results might be based either on user account (if your system has them) or session id.

Re: Recently viewed products - how do u do it?

Posted: Thu May 19, 2011 9:59 am
by kevrelland
Kastor wrote:Store them in cookie on client side
yea agree cookie on the client side the easiest