From: Michael Widenius Date: December 24 2009 11:18am Subject: re: mysys/hash.c List-Archive: http://lists.mysql.com/internals/37615 Message-Id: <19251.19958.371570.9836@narttu.askmonty.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi! >>>>> "Yan" == Yan Yu writes: Yan> Dear MySQL experts: Yan> Thank you so much for your reply to my previous Qs, they are very Yan> helpful! Yan> Could someone please help me understand function my_hash_insert() Yan> in mysys/hash.cc? Yan> what are lines 352 -429 trying to achieve? Are they just some Yan> optimization to shuffle existing Yan> hash entries in the table (since the existing hash entries may be in Yan> the wrong slot due to chaining Yan> in the case of hash collision)? The hash algorithm is based on dynamic hashing without empty slots. This means that when you insert a new key, in some cases a small set of old keys needs to be moved to other buckets. This is what the code does. Regards, Monty