Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 15C7F1B9FCD8 for ; Thu, 1 Dec 2011 02:12:00 -0400 (AST) Received: from 2605ds1-ynoe.0.fullrate.dk ([90.184.12.24] helo=shrek.krogh.cc) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RVzsF-0007X1-KY for pgsql-performance@postgresql.org; Thu, 01 Dec 2011 06:12:00 +0000 Received: from localhost (localhost [127.0.0.1]) by shrek.krogh.cc (Postfix) with ESMTP id 9C4BBC44AAF; Thu, 1 Dec 2011 07:11:45 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at shrek.krogh.cc Received: from shrek.krogh.cc ([127.0.0.1]) by localhost (shrek.krogh.cc [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NwbCdDnZQHiX; Thu, 1 Dec 2011 07:11:41 +0100 (CET) Received: from [90.184.13.151] (2605ds1-ynoe.2.fullrate.dk [90.184.13.151]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jesper@krogh.cc) by shrek.krogh.cc (Postfix) with ESMTPSA id 1E0DC3316F6; Thu, 1 Dec 2011 07:11:41 +0100 (CET) Message-ID: <4ED71A9C.5030603@krogh.cc> Date: Thu, 01 Dec 2011 07:11:40 +0100 From: Jesper Krogh User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: Robert Haas CC: Rauan Maemirov , Kevin Grittner , pgsql-performance@postgresql.org Subject: Re: Problems with FTS References: <4D0CA1890200002500038774@gw.wicourts.gov> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201112/1 X-Sequence-Number: 45801 On 2011-11-30 21:58, Robert Haas wrote: > The row-count estimates look reasonably accurate, so there's some > other problem here. What do you have random_page_cost, seq_page_cost, > and effective_cache_size set to? You might try "SET > random_page_cost=2" or even "SET random_page_cost=0.5; SET > seq_page_cost=0.3" and see if those settings help I may be seing ghosts here, since I've encountered the same problem. But the Query-planner does not take toast into account, so a Sequential Scan + filter only cost what it takes to scan the main table, but fts-fields are typically large enough to be toasted so the cost should be main+toast (amount of pages) + filtering cost. I posted about it yesterday: http://archives.postgresql.org/pgsql-hackers/2011-11/msg01754.php If above problem is on <9.1 a patch to proper account of gin-estimates have been added to 9.1 which also may benefit the planning: http://www.postgresql.org/docs/9.1/static/release-9-1.html Improve GIN index scan cost estimation (Teodor Sigaev) Jesper -- Jesper