title: What's the fastest way to subset a data.table?
body: <p>It seems to me the fastest way to do a row/col subset of a <code>data.table</code> is to use the join and <code>nomatch</code> option.</p>
  
  <p>Is this correct?</p>
  
  <pre><code>DT = data.table(rep(1:100, 100000), rep(1:10, 1000000))
  setkey(DT, V1, V2)
  system.time(DT[J(22,2), nomatch=0L])
  # user  system elapsed 
  # 0.00    0.00    0.01 
  system.time(subset(DT, (V1==22) &amp; (V2==2)))
  # user  system elapsed 
  # 0.45    0.21    0.67 
  
  identical(DT[J(22,2), nomatch=0L],subset(DT, (V1==22) &amp; (V2==2)))
  # [1] TRUE
  </code></pre>
  
  <p>I also have one problem with the fast join based on binary search: I cannot find a way to select all items in one dimension.</p>
  
  <p>Say if I want to subsequently do:</p>
  
  <pre><code>DT[J(22,2), nomatch=0]  # subset on TWO dimensions
  DT[J(22,), nomatch=0]   # subset on ONE dimension only
  # Error in list(22, ) : argument 2 is empty
  </code></pre>
  
  <p>without having to re-set the key to only one dimension (because I am in a loop and I don't want to rest the keys every time).</p>