Cost of the query

  • (A, B, C)
  • (D, F, E)
  • (G, H)

Calculate output size of

  • Output size of is
  • Output size of is

Let the previous output be of size Both joins are hash joins, calculate cost of the query

  • Cost of join on is
  • Cost of selection is , it is pipelined
  • Cost of join on is

Total cost is

Sorted clustered index on , first join is a nested join loop, second join is a sort merge join

  • Cost of join on is
  • Cost of selection is again 0
  • Cost of join on is

Total cost is

Sorted clustered index on and on , both joins are sort-merge joins

  • Cost of join on is
  • Cost of selection is again 0
  • Cost of join on is

Total cost is


  • (A, B, C)
  • (D, E)

Calculate output size of

  • Output size of is
  • Output size of is

Let the previous output be of size Calculate cost of the query given both joins are nested loop joins

  • Cost of selection is
  • Cost of join on is
  • Cost of join on is

Total cost is

Sorted clustered index on , both joins are hash joins

  • Cost of selection is
  • Cost of join on is
  • Cost of join on is

Total cost is