Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 127E9D84656 for ; Fri, 8 Jun 2012 08:52:16 -0300 (ADT) Received: from moutng.kundenserver.de ([212.227.17.9]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Scxjh-0001Md-P7 for pgsql-performance@postgresql.org; Fri, 08 Jun 2012 11:52:15 +0000 Received: from obelix.localnet (AToulouse-556-1-160-221.w92-162.abo.wanadoo.fr [92.162.24.221]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0MYpHi-1SQE0X1Y3u-00VSko; Fri, 08 Jun 2012 13:51:55 +0200 From: =?iso-8859-1?q?C=E9dric_Villemain?= Reply-To: cedric@2ndquadrant.com Organization: 2ndQuadrant To: pgsql-performance@postgresql.org Subject: Re: non index use on LIKE on a non pattern string Date: Fri, 8 Jun 2012 13:51:50 +0200 User-Agent: KMail/1.13.7 (Linux/3.2.0-2-amd64; KDE/4.7.4; x86_64; ; ) Cc: Guillaume Cottenceau References: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3006149.DoTBXYWyLt"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201206081351.54589.cedric@2ndquadrant.com> X-Provags-ID: V02:K0:SFeyEDpJaxEtvdEikQDtZRK2KfsxkO4x8vLVosOWd12 zTTHe1NCl/QpuE9fJ29SdcTrHbZqX89v6Z3HmqKLvvAcJfdMA9 YRW9TXCSIWyQC9yEXf7fFNKO0Y5IOQN8ShZyeWZCvAC1RM/ZlL nDVrW2g3SRJFniBzN5oQ1NEEIuYHOR9Nts5ILd6Y0Hd+m2uM1K 8ORFztWWHPaWvu3Y4+698gP+5MRP+DQLwOlzyw8oktnf4REFku BnW3xHL1TCdwhGT5WOIKevhniMD5vzXUYwj9TUrbOtMi93e//k 5yOA5U5J5xs15Goge7CHqfNdZXhui0K7/tGklQ35IAFgj8lrl/ kEqRLNcvFl6uLTpNaU2nHewTFWke7yWoYqf4hfDJF X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/39 X-Sequence-Number: 47065 --nextPart3006149.DoTBXYWyLt Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable > I have noticed that with a SELECT query containing the following > constraint: >=20 > column LIKE ? >=20 > and an index on that column, PostgreSQL will not use the index > even if the parameter doesn't contain special pattern characters > such as %. you should have a postgresql 8.3,isn't it ? like is equal to "=3D" in your case, since 8.4 Also you probably want to have a look at http://www.postgresql.org/docs/9.1/static/indexes-opclass.html=20 about your index definition (add the "text_pattern_ops" when required) =2D-=20 C=E9dric Villemain +33 (0)6 20 30 22 52 http://2ndQuadrant.fr/ PostgreSQL: Support 24x7 - D=E9veloppement, Expertise et Formation --nextPart3006149.DoTBXYWyLt Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAABAgAGBQJP0edWAAoJENsgH0yzVBebTk8H/AscWiexH8h/yTR9wtRisnQO xEwOmgjqAMb9azzQ5HnKEGjSGGLocZGj/lJ8ZLQZ6uODgVkg2Vo2DWqIaLaKKKsL G7Yq54c47nekl1IJ+UcXBUt14qdB8TfU4Eii213J3M8gBomsUHOljhqFRqYEALqW jvjiiHr8r9sidqU0GQTrF2NfKjejXe/Ft8G8OT4h8lFXZLW4tw+WAzbE4z+7FON0 +SOoDIK9Jq640P/jpZAXUWez5WPRT1Qx5JT74KtsF3hiZOf1AP2Z/MEwkyJuSeQm ILw1F4YlcSlRbBWif0s8S85cdVzVnMb38Nz4W4z5Be0HW2dwjysR/JNhF1WH/4g= =oYHM -----END PGP SIGNATURE----- --nextPart3006149.DoTBXYWyLt--