K
K
Kot Matpockuh2017-11-04 16:05:54
Algorithms
Kot Matpockuh, 2017-11-04 16:05:54

How to implement a quick table comparison?

Hello.
There are, let's say 3 tables with fields:
brand | article | price
It is necessary to aggregate from three files "one".
brand | article | price1 | price2 | price3
How can 3 tables be compared?
Of course, you can run a loop and compare each row of each table with the other two. But... When there are 100,000+ such positions, of course, it will take too much time and memory.
Now there are absolutely no ideas, which algorithm from the "classics of the genre" could help me now ...
Maybe someone will have some ideas?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2017-11-04
@Rsa97

Are "tables" arrays in memory? Then sort all the arrays by brand and article, then moving in parallel through all three arrays to form a common one.

R
Roman Mirilaczvili, 2017-11-04
@2ord

If solving the problem non-algorithmically, then I would use SQLite (in memory) or another RDBMS (temporary table):
you can insert values ​​row by row, then write an SQL query that selects with the appropriate aggregation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question