Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id D6DEE650511 for ; Wed, 26 Nov 2008 15:55:00 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 41265-04 for ; Wed, 26 Nov 2008 15:54:56 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from fhw-relay07.plus.net (fhw-relay07.plus.net [212.159.14.148]) by mail.postgresql.org (Postfix) with ESMTP id 2E0F46504ED for ; Wed, 26 Nov 2008 15:54:56 -0400 (AST) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by fhw-relay07.plus.net with esmtp (Exim) id 1L5QTN-0003l4-Ta; Wed, 26 Nov 2008 19:54:54 +0000 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id BE56327406A; Wed, 26 Nov 2008 19:54:53 +0000 (GMT) Message-ID: <492DA98D.4050704@archonet.com> Date: Wed, 26 Nov 2008 19:54:53 +0000 From: Richard Huxton User-Agent: Thunderbird 2.0.0.18 (X11/20081105) MIME-Version: 1.0 To: Andrus CC: mweilguni@sime.com, pgsql-performance@postgresql.org Subject: Re: Increasing pattern index query speed References: <492A7591.3000700@archonet.com> <492D27C8.7090206@archonet.com> <4936D68EF8C84087BBB9212C4019D5D8@andrusnotebook> <492D9E78.9080902@archonet.com> In-Reply-To: Content-Type: text/plain; charset=windows-1257 Content-Transfer-Encoding: 7bit X-Plusnet-Relay: b2767491caeff18110cba0d23249bf81 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200811/267 X-Sequence-Number: 31998 Andrus wrote: > Richard, > >> And the results were? > > Results are provided in bottom of the message to which you replied. No - the explains there were contrasting a date test BETWEEN versus =. >> One problem at a time. Let's get the pattern-matching speed problems on >> your live server sorted, then we can look at different queries. > > First message in this thread described the issue with query having > additional condition > > AND dok.kuupaev BETWEEN '2008-11-21' AND '2008-11-21' Ah, I think I understand. The test case was *missing* this clause. > It seems that this problem occurs when pattern matching and BETWEEN > conditions are used in same query. > > According to Scott Garey great recommendation I added > > ALTER TABLE rid ALTER COLUMN toode SET STATISTICS 1000; > > This fixes testcase in live server, see my other message. > Is it OK to run > > ALTER TABLE rid ALTER COLUMN toode SET STATISTICS 1000 > > in prod database or should I try to decrease 1000 to smaller value ? > rid is big increasing table and is changed frequently, mostly by adding > rows. This will try to track the 1000 most-common values of "toode", whereas the default is to try to track the most common 10 values. Tracking more values means the planner has more accurate information but makes ANALYSE take longer to run, and also makes planning each query take slightly longer. Try 100, 200, 500 and see if they work *for a range of queries* - there's no point in having it much higher than it needs to be. -- Richard Huxton Archonet Ltd