|R| = 10000 tuples, 10 tuples with a=5, R is indexed on a -- Cost of execution for rec in select * from R loop if (rec.a = 5) then ... end if; end loop; #iterations = 10000 for rec in select * from R where a = 5 loop ... end loop; #queries = 10