Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have two databases

DB1 - postgres on server 1
DB2 - mysql on server2

  1. getting userids from DB2 from user_address table
  2. passing userid to DB1 to user table and fetch user details
  3. iterate step 1) data and assign user details based on user ids

How do I optimize my code to skip iteration in step3?

share|improve this question

put on hold as unclear what you're asking by Neil Stockton, Alex K, greg-449, arulmr, EdChum 16 hours ago

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

    
What have you got currently? This is not a free code-writing service. – geisterfurz007 17 hours ago
1  
Create a foreign data wrapper in Postgres pointing to the MySQL table and do it in a single query on the Postgres side, e.g. select * from user_table where id in (select id from mysql_fdw_table) – a_horse_with_no_name 17 hours ago