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?
Recently viewed products - how do u do it?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Recently viewed products - how do u do it?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Recently viewed products - how do u do it?
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?
Store them in cookie on client side
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: Recently viewed products - how do u do it?
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.simonmlewis wrote:Is there a better way to do this?
-
kevrelland
- Forum Commoner
- Posts: 73
- Joined: Mon Jan 08, 2007 7:41 am
Re: Recently viewed products - how do u do it?
yea agree cookie on the client side the easiestKastor wrote:Store them in cookie on client side