title: Filtering eligible records for authorization - Is a rules engine right solution?
body: <p>I have an authorization screen for say payments</p>
  
  <p>A list of transactions is displayed. This is a filtered list. 
  Each transaction listed in this screen needs to satisfy following conditions</p>
  
  <p>A) Meets Authorization Verification Matrix (AVM) conditions</p>
  
  <p>B) .. few more conditions not imp at this time</p>
  
  <p>In simplest form AVM is defined as below</p>
  
  <blockquote>
    <ul>
    <li>Below 5000 -- ApproverRole</li>
    <li>Above 5000 -- SeniorApproverRole</li>
    </ul>
  </blockquote>
  
  <p>Hence if the loggedIn user belongs to ApproverRole , all the transactions which are below 5000 should be displayed.</p>
  
  <p>I am trying to solve this problem using drools.</p>
  
  <p><strong>Proposed solution.</strong></p>
  
  <ul>
  <li>Create a rule "AVMRULE"</li>
  <li>Each payment is modeled as a FACT.</li>
  </ul>
  
  <p>Payment has two interesting properties 
  1) amount 
  2) isEligible</p>
  
  <blockquote>
    <p>When payment object is asserted into working memory the "AVMRULE" modifies the payment.isEligible. The user interface displays or hides the transaction based on payment.isEligible</p>
  </blockquote>
  
  <p><strong>Problem :</strong>
  Average number of payments in a system can go up to a million.
  The above solution implies that the application has to fetch all the million records to the business layer.</p>
  
  <p>It can be optimized to fetch batch of records and 
  stop reading as soon as we find first 10 records which have isEligible true. This works if the user wants to see first page. Doesn't work if he wants to see the last page. 
  I am not sure if overall performance will improve in a multi-user environment at-least 20 concurrent users</p>
  
  <p><b>Question : </b>
  Please note the problem is to display the filtered list. 
  Also consider that there are more conditions to handle and AVM is much complex than what is defined above.</p>
  
  <p><strong>Is rules engine appropriate to solve this problem ?</strong></p>
  
  <p><strong>Is this the right approach ?</strong></p>
  
  <p><strong>Has any one solved similar problem ?</strong></p>
  
  <p><strong>Are there any guide lines on how to minimize number of records fetch to business layer?</strong></p>