title: what is the Time complexity of redis del command?
body: <p>the offical document about del command: </p>
  
  <blockquote>
    <p>Time complexity: O(N) where N is the number of keys that will be removed. When a key to remove holds a value other than a string, the individual complexity for this key is O(M) where M is the number of elements in the list, set, sorted set or hash. Removing a single key that holds a string value is O(1).</p>
  </blockquote>
  
  <p>why? I think even if  the key refers to a complex type, the Time complexity of del should  always is  O(1) 。  the redis db find the hash value of the key and remove it，which operation Time complexity is O(1)。</p>
  
  <p>in the redis souce code,the implement of "del command" is as follow:</p>
  
  <pre><code>void delCommand(client *c) {
      int deleted = 0, j;
  
      for (j = 1; j &lt; c-&gt;argc; j++) {
          expireIfNeeded(c-&gt;db,c-&gt;argv[j]);
          if (dbDelete(c-&gt;db,c-&gt;argv[j])) {
              signalModifiedKey(c-&gt;db,c-&gt;argv[j]);
              notifyKeyspaceEvent(NOTIFY_GENERIC,
                  "del",c-&gt;argv[j],c-&gt;db-&gt;id);
              server.dirty++;
              deleted++;
          }
      }
      addReplyLongLong(c,deleted);
  }
  </code></pre>
  
  <p>as above,deleting 1 key should has a complexity of O(1),regardless of a complex type。</p>