title: postgreSQL explain analyze, relation between actual time and estimation
body: <p><a href="https://wiki.postgresql.org/wiki/Introduction_to_VACUUM,_ANALYZE,_EXPLAIN,_and_COUNT" rel="nofollow">https://wiki.postgresql.org/wiki/Introduction_to_VACUUM,_ANALYZE,_EXPLAIN,_and_COUNT</a></p>
  
  <p>I am currently reading this page to understand EXPLAIN ANALYZE for postgreSQL, and I am trying to understand the relation between the estimation cost and actual time.</p>
  
  <p>A simple example given in this page is as following:</p>
  
  <pre><code>-&gt;  Nested Loop  (cost=5.64..14.71 rows=1 width=140) (actual time=18.983..19.481 rows=4 loops=1)
                 -&gt;  Hash Join  (cost=5.64..8.82 rows=1 width=72) (actual time=18.876..19.212 rows=4 loops=1)
                 -&gt;  Index Scan using pg_class_oid_index on pg_class i  (cost=0.00..5.88 rows=1 width=72) (actual time=0.051..0.055 rows=1 loops=4)
  </code></pre>
  
  <p>and it says " If you do the math, you'll see that 0.055 * 4 accounts for most of the difference between the total time of the hash join and the total time of the nested loop (the remainder is likely the overhead of measuring all of this)."</p>
  
  <p>I am not sure what does the "difference" here stand for and i cannot really find any difference which is close to 0.055 *4.. Am i silly that just ignore some trivial result?</p>
  
  <p>Btw i am actually writing a lab report on databases, so generally if being asked to write down some brief comment on estimated and actual time based on some specific result, what can i say?</p>
  
  <p>this is the plan i need to write result on:</p>
  
  <pre><code>QUERY PLAN                                                               
  ---------------------------------------------------------------------------------------------------------------------------------------
   Nested Loop  (cost=39911.52..299300.41 rows=1 width=17) (actual time=4660.217..4952.328 rows=1 loops=1)
     Join Filter: (casts.mid = movie.id)
     Rows Removed by Join Filter: 2251735
     -&gt;  Seq Scan on movie  (cost=0.00..29721.64 rows=5542 width=21) (actual time=0.637..316.651 rows=4201 loops=1)
           Filter: (year &gt; 2010)
           Rows Removed by Filter: 1533210
     -&gt;  Materialize  (cost=39911.52..269080.01 rows=6 width=4) (actual time=0.307..1.014 rows=536 loops=4201)
           -&gt;  Hash Join  (cost=39911.52..269079.98 rows=6 width=4) (actual time=1288.827..4089.872 rows=536 loops=1)
                 Hash Cond: (casts.pid = actor.id)
                 -&gt;  Seq Scan on casts  (cost=0.00..186246.47 rows=11445847 width=8) (actual time=0.293..1487.138 rows=11445847 loops=1)
                 -&gt;  Hash  (cost=39911.51..39911.51 rows=1 width=4) (actual time=414.130..414.130 rows=1 loops=1)
                       Buckets: 1024  Batches: 1  Memory Usage: 1kB
                       -&gt;  Seq Scan on actor  (cost=0.00..39911.51 rows=1 width=4) (actual time=100.175..414.125 rows=1 loops=1)
                             Filter: (((fname)::text = 'Tom'::text) AND ((lname)::text = 'Hanks'::text))
                             Rows Removed by Filter: 1865033
   Total runtime: 4952.822 ms
  </code></pre>