X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id 2FE7611F65E7 for ; Tue, 18 Apr 2006 13:26:22 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -2.421 X-Spam-Level: X-Spam-Status: No, score=-2.421 required=5 tests=[AWL=0.043, BAYES_00=-2.599, FORGED_RCVD_HELO=0.135] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id NPygItBCr9qZ for ; Tue, 18 Apr 2006 13:26:13 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by postgresql.org (Postfix) with ESMTP id B6E7311F65CA for ; Tue, 18 Apr 2006 13:26:07 -0300 (ADT) Received: from [213.162.97.75] (helo=mail.metronet.co.uk) by ptb-relay01.plus.net with esmtp (Exim) id 1FVt1X-0008Cr-EJ; Tue, 18 Apr 2006 17:25:55 +0100 Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id DE0A1735C0; Tue, 18 Apr 2006 17:28:22 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 211B615EA4; Tue, 18 Apr 2006 17:25:44 +0100 (BST) Message-ID: <44451307.2080706@archonet.com> Date: Tue, 18 Apr 2006 17:25:43 +0100 From: Richard Huxton User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: "Tarabas (Manuel Rorarius)" Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: [bulk] Re: Problem with LIKE-Performance References: <341367953.20060418163513@tarabas.de> <13458.1145373620@sss.pgh.pa.us> <653249740.20060418173459@tarabas.de> <13754.1145375139@sss.pgh.pa.us> <492687293.20060418180434@tarabas.de> In-Reply-To: <492687293.20060418180434@tarabas.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200604/386 X-Sequence-Number: 18470 Tarabas (Manuel Rorarius) wrote: > Hi Tom, > > TL> As already noted, it might be worth your while to add an index using the > TL> pattern-ops opclass to help with queries like this. > > I have done that now and it works very fine as supposed. > > The problem with the high startup_costs disappeared somehow after the > change of the enable_seqscan = off and a restart of pg-admin. I'm not sure restarting pgAdmin would have had any effect. > first Time I ran the statement it showed 13 sec execution time. > > Seq Scan on image image0_ (cost=0.00..21414.21 rows=11 width=1311) > (actual time=10504.138..12857.127 rows=119 loops=1) > Filter: ((title)::text ~~ '%Davorka%'::text) > Total runtime: 12857.372 ms > > second time I ran the statement it dropped to ~500 msec , which is > pretty ok. :-) This will be because all the data is cached in the server's memory. > Seq Scan on image image0_ (cost=0.00..21414.21 rows=11 width=1311) > (actual time=270.289..552.144 rows=119 loops=1) > Filter: ((title)::text ~~ '%Davorka%'::text) > Total runtime: 552.708 ms As you can see, the plan is still scanning all the rows. In any case, you've changed the query - this has % at the beginning and end, which no index will help you with. -- Richard Huxton Archonet Ltd