title: Query Plan of postgres with indexes
body: <p>I have a postgres table having the following schema</p>
  
  <pre><code>     Table "public.myTable"
    Column               |           Type           | Modifiers 
  -----------             +--------------------------+-----------
   serial_number         | character varying(255)   | 
   name                  | character varying(255)   | 
   Designation           | character varying(255)   | 
   place                 | character varying(255)   | 
   timeOfJoining         | timestamp with time zone | 
   timeOfLeaving               | timestamp with time zone | 
  
  Indexes:
      "name_Designation_place" btree (name, Designation, place)
      "Designation_place_name" btree (Designation, place, name)
      "Designation_name_place" btree (Designation, name, place)
      "timeOfJoining_timeOfLeaving" btree (timeOfJoining, timeOfLeaving)
      "timeOfJoining_timeOfLeaving" btree (timeOfJoining, timeOfLeaving)
  </code></pre>
  
  <p>Now when I run the query of the form: </p>
  
  <pre><code>explain analyze select place from myTable where Designation='Manager' and timeOfJoining&gt;'1930-10-10';
  </code></pre>
  
  <p>I am getting the following plan:</p>
  
  <pre><code>Index Scan using Designation_place_name on myTable  (cost=0.00..67701.36 rows=22043 width=27) (actual time=0.061..3.796 rows=3376 loops=1)
     Index Cond: ((relation)::text = 'Manager'::text)
     Filter: (timeOfJoining &gt; '1930-10-10 00:00:00+05:53:20'::timestamp with time zone)
   Total runtime: 4.082 ms
  (4 rows)
  </code></pre>
  
  <p>Now I am unable to understand as to how the query plan is executed. Does the query plan first retrieve the serial_number from the index Designation_place_name on myTable and then goes to myTable and fetches the rows and then performs the filtering on timeOfJoining</p>
  
  <p>OR</p>
  
  <p>Does the query plan fetch both the indexes timeOfJoining_timeOfLeaving and Designation_place_name and then performs a join, and upon this join the filtering is done?</p>