Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 2B7149FB3E8 for ; Tue, 24 Oct 2006 04:01:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 85465-02 for ; Tue, 24 Oct 2006 07:00:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 3B61D9FA4AE for ; Tue, 24 Oct 2006 04:00:15 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by svr4.postgresql.org (Postfix) with ESMTP id 5F9A45AF8D7 for ; Tue, 24 Oct 2006 07:00:13 +0000 (GMT) Received: from db2.internal (db2.internal [10.202.2.12]) by frontend1.messagingengine.com (Postfix) with ESMTP id C3715DB9106; Tue, 24 Oct 2006 03:00:11 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by db2.internal (MEProxy); Tue, 24 Oct 2006 03:00:13 -0400 X-Sasl-enc: VbkfUSYTXI8qjMiF3j/z7KfEWkNEhGQ2mDS9MIcgYuBI 1161673212 Received: from [203.127.152.35] (carl-sgc-sg-1.inter-touch.net [203.127.152.2]) by mail.messagingengine.com (Postfix) with ESMTP id D17CE1B30D; Tue, 24 Oct 2006 03:00:11 -0400 (EDT) Message-ID: <453DB9F1.7050204@stuartbishop.net> Date: Tue, 24 Oct 2006 15:00:01 +0800 From: Stuart Bishop User-Agent: Thunderbird 1.5.0.7 (X11/20060922) MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Slow functional indexes? References: <45387666.204@canonical.com> <20906.1161401432@sss.pgh.pa.us> In-Reply-To: <20906.1161401432@sss.pgh.pa.us> X-Enigmail-Version: 0.94.0.0 OpenPGP: id=BAC6374A; url=http://stuartbishop.net/stuartbishop.asc Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigAFCF518133706AF2C6E0A53F" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200610/498 X-Sequence-Number: 21627 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigAFCF518133706AF2C6E0A53F Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Tom Lane wrote: > Stuart Bishop writes: >> I would like to understand what causes some of my indexes to be slower= to >> use than others with PostgreSQL 8.1. >=20 > I was about to opine that it was all about different levels of > correlation between the index order and physical table order ... but > your experiments with freshly clustered indexes seem to cast doubt > on that idea. Are you sure your function is really immutable? A buggy= > function could possibly lead to a "clustered" index not being in > physical order. Definitely immutable. Here is the function definition: CREATE OR REPLACE FUNCTION person_sort_key(displayname text, name text) RETURNS text LANGUAGE plpythonu IMMUTABLE RETURNS NULL ON NULL INPUT AS $$ # NB: If this implementation is changed, the person_sort_idx needs to= be # rebuilt along with any other indexes using it. import re try: strip_re =3D SD["strip_re"] except KeyError: strip_re =3D re.compile("(?:[^\w\s]|[\d_])", re.U) SD["strip_re"] =3D strip_re displayname, name =3D args # Strip noise out of displayname. We do not have to bother with # name, as we know it is just plain ascii. displayname =3D strip_re.sub('', displayname.decode('UTF-8').lower())= return ("%s, %s" % (displayname.strip(), name)).encode('UTF-8') $$; --=20 Stuart Bishop http://www.stuartbishop.net/ --------------enigAFCF518133706AF2C6E0A53F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFFPbnxAfqZj7rGN0oRAtWUAJ4wcSbRpUSV20YeOzl9tMvIVVzoHwCcCNcw 7S+QbgXhnjFkUbILPSgJE+A= =UEBm -----END PGP SIGNATURE----- --------------enigAFCF518133706AF2C6E0A53F--