X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 471969DC842 for ; Fri, 20 Jan 2006 17:44:03 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85768-05 for ; Fri, 20 Jan 2006 17:44:01 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by postgresql.org (Postfix) with ESMTP id BF4B49DC809 for ; Fri, 20 Jan 2006 17:43:57 -0400 (AST) Received: from trofast.sesse.net ([129.241.93.32]) by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1F0432-0003FG-AJ for pgsql-performance@postgresql.org; Fri, 20 Jan 2006 22:43:56 +0100 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1F0438-0005ro-00 for ; Fri, 20 Jan 2006 22:44:02 +0100 Date: Fri, 20 Jan 2006 22:44:02 +0100 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: [GENERAL] Creation of tsearch2 index is very slow Message-ID: <20060120214402.GA22493@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <43D0ED57.1020608@gmx.de> <17454.1137771321@sss.pgh.pa.us> <20060120170452.GC31908@svana.org> <26153.1137784469@sss.pgh.pa.us> <20060120201036.GE31908@svana.org> <26583.1137788505@sss.pgh.pa.us> <20060120205132.GF31908@svana.org> <26958.1137791955@sss.pgh.pa.us> <20060120213754.GG31908@svana.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20060120213754.GG31908@svana.org> X-Operating-System: Linux 2.6.14.3 on a x86_64 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.11 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.068 required=5 tests=[AWL=0.068] X-Spam-Score: 0.068 X-Spam-Level: X-Archive-Number: 200601/365 X-Sequence-Number: 16843 On Fri, Jan 20, 2006 at 10:37:54PM +0100, Martijn van Oosterhout wrote: > Given that all it's doing is counting bits, a simple fix would be to > loop over bytes, use XOR and count ones. For extreme speedup create a > lookup table with 256 entries to give you the answer straight away... For extra obfscation: unsigned v = (unsigned)c; int num_bits = (v * 0x1001001001001ULL & 0x84210842108421ULL) % 0x1f; (More more-or-less intelligent options at http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetNaive :-) ) /* Steinar */ -- Homepage: http://www.sesse.net/