title: Searching on two separate PostgreSQL databases
body: <p>There are two applications (PHP - Symfony 2 - Doctrine 2) each of them has it's own PostgreSQL database.</p>
  
  <ul>
  <li><p>First one is central server (S) which is located in our place. It contains anonymised data from the customers.</p></li>
  <li><p>Second part (P) is located somewhere else - typically in customer's company - and contains some private data. The app is able to assign this private data to anonymised data from the server.</p></li>
  </ul>
  
  <p>We need to search and sort the data according to columns which are stored both on P and S. The problem is, that we can't send private data to the server. Data binding is not 1:1. One row on the (P) part can be assigned to 1 or more rows on the server (S).</p>
  
  <p>We can:</p>
  
  <ul>
  <li>search on the (P)</li>
  <li>send the IDs to the (S)</li>
  <li>(P) can't send the data, as the are private (only IDs), so the (S) part is not able to sort the result set and has to return all the relevant data, not only N results we need to display.</li>
  <li>complete the result set on the P part and return N results.</li>
  </ul>
  
  <p>Is there any way how to execute one query on two databases? DB-link is not an option - it is not stable enough for us.</p>
  
  <p>Is there any way how to sync search data from the S to the P in real time to search on one place? (Data on S may be changed from different place).</p>
  
  <p>Is there any better solution to this problem?</p>