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

  • SEARCH
  • Home
  • 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 9273367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:05:54+00:00 2026-06-18T16:05:54+00:00

I have a quite interesting task. But I don’t know how to call it

  • 0

I have a quite interesting task. But I don’t know how to call it in one word in order to search for related topics. Even this topic title might not reflect what I need. So, if somebody has better title – welcome.

I’ll try to explain my problem.

I have about 100,000 rows in MySQL db table. And I need to “compare” entries from the table.

“compare” doesn’t mean just equal. There is an algorithm for calculation comparison level. I have weight coefficient for each table column. Means that if entry#1’s column1 equals to entry#2’s column2 then I give, say, 5 point to this pair. And so on for each column.

The most straight forward way to do this – apply calculation rules for each couple of entries. Why am I afraid of this? 100,000 entries means about 5 billion “compare” operations. For sure, I can calculate this on demand and store the result somewhere in cache. But I believe that the most obvious way is not the most effective.

So, my first question is: Is there any other better way to achive my goal except of brute force?

My second question is related to tool which is better for calculations.

  1. Application language is PHP. Hence, I need to load into memory whole
    table and iterate over the data.
  2. Create stored procedure in MySQL.
  3. Using MongoDB’s aggregation framework or MapReduce.

The least of all I like the first way. The most of all – the last.

I’m looking for any suggestion or advice from people who have experience in such sort of cases.

Since, I don’t know how to ask google for help, any links will be appreciated.

UPDATE:

Calculation rules are a bit more complicated then I described…

Table has a set of related columns which are to be used at once as group(not one by one).
Let’s assume:

table has fields, say, tag_1, tag_2, .., tag_n.
row_1 and row_2 – entries in the table.

The rule(pseudo-code):

if(row_1.tag_1==row_2.tag_1)
{
    // gives 10 points
}
elseif(row_1.tag_1 is in row_2.tags && row_1.tag_1!=row_2.tag_1)
{
    // gives 5 points
}
....
// and so on

Basically, I need to check find intersection of two arrays. If it is not empty – points are given. If indexes of tags in two rows match the additional points are given.

I’m wondering, how this can be accomplished using Stored Procedures Language? Because it can be done pretty easy using any programming language.

If stored procedure can do this then it is my choice.

  • 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-06-18T16:05:55+00:00Added an answer on June 18, 2026 at 4:05 pm

    If you have a static table, then it doesn’t make a difference which you choose, so long as you store the results somewhere (presumably back in the database).

    If your data is changing, then you need to compare each new row to all rows, which is essentially a full-table scan. This is probably best done in a database.

    If the data fits into memory (and 500,000 rows should fit into memory), then (2) will probably be faster than (3) on equivalent hardware. “Equivalent hardware” is a very important consideration.

    In most cases, I would opt for (2). It sounds like the query is something like:

    select t.id, t2.id,
           ((case when t1.col1 = t2.col1 then 5 else 0 end) +
            (case when t2.col2 = t2.col2 then 7 else 0 end) +
            . . .
           )
    from t cross join t2
    

    If you are much more comfortable with map-reduce, then you might find it easier to code there. I know both languages and prefer SQL for something like this.

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

Sidebar

Related Questions

I have recently started diving into Haskell. Its quite interesting, but the definition of
I have quite an interesting task at work - I need to find out
I have quite big document in html format that generated from Microsoft Word. It
I have quite a lot of music files but their title attributes have the
I have a quite interesting issue. I set some values on the server, send
I recently came across the link below which I have found quite interesting. http://en.wikipedia.org/wiki/XOR_linked_list
We're seeing an interesting (though quite severe) issue with one of our application servers:
This is a quite interesting question, in my opinion. I have a strongly typed
I am facing a quite interesting but annoying error, in my linear layout i
I have ran into quite an interesting mapping scenario. I have two entities (

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.