I currently work for a social networking website.
My boss recently had the idea to show search results by random instead of normal results (registration date). The problem with that is simple and obvious: if you go from one page to another, it's going to show you different results each time as the list is randomized each time.
I had the idea to store results in database+cookies something like this:
- Cookie containing a serialized version of the $_POST request (needed if we want to do a re-sort)
- A table which would serve as the base for the search id => searches (id,user
_id, creation
_date) - A table which would store the results and their order => searches
_results (search_id, order, user
_id)
Flow chart would look like something like that:
- After each searches I store the "where" into a cookie or session
- Then I erase the previous search in "searches"
- Then I delete previous results in "searches_results"
- Then I insert a row into "searches" for the key
- Then I insert each user row into "searches_results"
- And finally I redirect the user to somethink like ?search_id=[search_key]
There is a big flaw here : performances .... it is definetly possible to make the system OR down OR very slow.
Any idea what would be the best to structure this ?