Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 926891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:45:44+00:00 2026-05-15T19:45:44+00:00

I am trying to create a system which would be able to find users

  • 0

I am trying to create a system which would be able to find users with similar favourite movies/books/interests/etc., much like neighbours on last.fm. Users sharing the most mutual interests would have the highest match and would be displayed in user profiles (5 best matches or so).

Is there any reasonably fast way to do this? The obvious solution would be to create a table with user ids and interest ids and compare a user with all the other users, but that would take forever on a table with … say million users each having 20 interests.

I assume some efficient solution exists, since last.fm is working quite well. I would prefer using some common SQL database like mySQL or pgSQL, but anything would do.

Thanks for your suggestions.


UPDATE:
As it turns out, the biggest problem is finding nearest neighbours in SQL databases, as none of the open-source ones supports this kind of search.
So my solution would be to modify ANN to run as a service and query it from PHP (using sockets for instance) – having even millions of users with say 7 dimensions in memory is not so much of a big deal and it runs unbelievably fast.

Another solution for smaller datasets is this simple query:

SELECT b.user_id, COUNT(1) AS mutual_interests
FROM `users_interests` a JOIN `users_interests` b ON (a.interest_id = b.interest_id)
WHERE a.user_id = 5 AND b.user_id != 5
GROUP BY b.user_id ORDER BY mutual_interests DESC, b.user_id ASC

20-50ms with 100K users each having ~20 interests (of 10 000 possible interests) on average

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:45:45+00:00Added an answer on May 15, 2026 at 7:45 pm

    You want to solve the approximate nearest neighbor problem. Encode users characteristics as a vector in some space, and then find approximately the nearest other user in that space.

    What space exactly, and what distance metric you want to use are probably things to evaluate experimentally based on your data. Fortunately, there is a C++ package you can use to solve this problem with various metrics and algorithms to fit your needs: http://www.cs.umd.edu/~mount/ANN/

    Edit: Its true that the running time here is dependent on the number of features. But there is a handy theorem in high-dimensional geometry that says that if you have n points in arbitrarily high dimensions, and you only care about approximate distances, you can project them down into O(log n) dimensions without loss. See here (http://en.wikipedia.org/wiki/Johnson-Lindenstrauss_lemma). (A random projection is performed by multiplying your points by a random +1/-1 valued matrix). Note that log(1,000,000) = 6, for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a generic Identifier class which I would be able
I'm trying to create a game save system which involves saving a score for
im trying to create a badge system similar to stackoverflows. i noticed that stackoverflow
I am trying to create a messaging system between users and organizations - that
I am trying to create a point system in my program similar to stack
I am trying to create a PHP commenting system similar to facebooks wall but
I'm trying to create routes which follow the structure of a tree navigation system,
I'm trying to create a very basic chat system, part of which will be
I'm trying to create a system in Python in which one can select a
I am trying to create system configuration for my module.After adding system.xml I'm getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.