Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3D51EB5DBC4 for ; Mon, 19 Sep 2011 12:54:36 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 02159-06 for ; Mon, 19 Sep 2011 15:54:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail-bw0-f46.google.com (mail-bw0-f46.google.com [209.85.214.46]) by mail.postgresql.org (Postfix) with ESMTP id 48AE3B5DC3C for ; Mon, 19 Sep 2011 12:54:28 -0300 (ADT) Received: by bkbzt4 with SMTP id zt4so5410781bkb.19 for ; Mon, 19 Sep 2011 08:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=FWgiKSzjFxPwfiJcgmdLnK+PTU+g1qanzH8VWPLp29Q=; b=KYMx2tGdd5ERRKk/GumBIb7khCekoy2E8UrfL/5ezx+iK6MwMqePcabVlbPlkSCLoV Dd9/D5IZoHI7kxiSpvMYDAHj3bRh1/XcMZN3F9RQjso8yH/dZHMiJtgfRb6oKX+WBZRG gdaqIGQTxfrCyI6XCIKi+y0nqdjBIzd9qe52g= Received: by 10.204.145.209 with SMTP id e17mr1726377bkv.221.1316447667208; Mon, 19 Sep 2011 08:54:27 -0700 (PDT) Received: from [10.64.1.26] ([94.45.140.16]) by mx.google.com with ESMTPS id y8sm14582125bkb.4.2011.09.19.08.54.25 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 19 Sep 2011 08:54:26 -0700 (PDT) Message-ID: <4E7765B0.4000900@gmail.com> Date: Mon, 19 Sep 2011 18:54:24 +0300 From: Vitalii Tymchyshyn User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2 Thunderbird/3.1.11 MIME-Version: 1.0 To: Robert Klemme CC: Merlin Moncure , Stefan Keller , Jeff Janes , Peter Geoghegan , pgsql-performance@postgresql.org Subject: Re: Hash index use presently(?) discouraged since 2005: revive or bury it? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.799 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=0.1, FREEMAIL_FROM=0.001 X-Spam-Level: X-Archive-Number: 201109/272 X-Sequence-Number: 45048 19.09.11 18:19, Robert Klemme написав(ла): > > I still haven't seen a solution to locking when a hash table needs > resizing. All hashing algorithms I can think of at the moment would > require a lock on the whole beast during the resize which makes this > type of index impractical for certain loads (heavy updating). Sorry for the second reply, I should have not start writing until I've read all your post. Anyway. Do you need read lock? I'd say readers could use "old" copy of hash table up until the moment new bigger copy is ready. This will simply look like the update is not started yet, which AFAIK is OK for MVCC. Yep, all the writers will wait. Another option could be to start background build of larger hash - for some time your performance will be degraded since you are writing to two indexes instead of one plus second one is rebuilding, but I'd say low latency solution is possible here. One more: I don't see actually why can't you have a "rolling" expand of hash table. I will try to describe it correct me if I am wrong: 1) The algorithm I am talking about will take "n" bits from hash code to for hash table. So, during expansion it will double number of baskets. 2) Say, we are going from 2^n = n1 to 2^(n+1) = n2 = n1 * 2 baskets. Each new pair of baskets will take data from single source basket depending on the value of new hash bit used. E.g. if n were 2, we've had 4 baskets and new table will have 8 baskets. Everything from old basket #1 will go into new baskets #2 and #3 depending on hash value. 3) So, we can have a counter on number of baskets processed. Any operation on any lower numbered basket will go to "new set". Any operation on any higher numbered basket will go to "old set". Any operation on currently converting basket will block until conversion is done. P.S. Sorry for a lot of possibly dumb thoughts, I don't know why I've got such a though stream on this topic :) Best regards, Vitalii Tymchyshyn.