Doubt: Intersection between different databases

Asked

Viewed 31 times

1

This POST is more of a question than a problem, I have the following scenario:

Two different databases, DB2 and PSQL, they contain records of monitor collections, I need to create an intersection between them (Db2xpsql) in PHP. I perform select in Databases, and save in arrays the results.

Example: $get_sql[] = odbc_result($result, "COLUMNNAME")

What I need to do is compare the column HOSTNAME which contains in the two databases and filter out what exists equally and differently between them, generating a table in the FRONT-END, I am using the native PHP function array_intersect() to take what is equal and array_diff() to take what’s different between them. After receiving what is equal in a new array, I pass this array inside a SELECT cloistered WHERE where its value is the intersection array, so it returns me the line of the intersection value with all the data, and not only the field of HOSTNAME, I need to generate this more effectively, because I’m talking about about 10,000 records in each database, and this way is creating a database overload. How would you make that intersection?

The question is not in the scope of the site but I believe I can help someone in the future with the same scenario, so I will keep it published!

  • 2

    By chance a Foreign-data wrapper would not meet your needs by solving in DBMS itself without having to do in php?

  • I hadn’t thought about it, I’ll engage more about, thanks for the tip!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.