Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8AE80B5DBDA for ; Thu, 30 Jun 2011 00:59:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 49728-02-3 for ; Thu, 30 Jun 2011 03:59:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pv0-f174.google.com (mail-pv0-f174.google.com [74.125.83.174]) by mail.postgresql.org (Postfix) with ESMTP id EC2DAB5DC1D for ; Thu, 30 Jun 2011 00:59:25 -0300 (ADT) Received: by pvg12 with SMTP id 12so1265683pvg.19 for ; Wed, 29 Jun 2011 20:59:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=BE77xnAPsp4Kkd7MTVvgJkonT/k5Hdu4sTZdGKlKvJY=; b=AXRJ3ZWQb8gkak6XGDEMrYKOtyi/UyBUPMKU0y8Mw2A8fJ280Ry84A6wDBGID2go53 IAfJ4Us5zsKICSCoAF0q34joHmEzHSVUYvOpy6TrmfykNzoTesWGh30Ddo6k6EVtXnHn gAjDoYdm9skN+GWfFf3jTH6vG4AgRT18y2mDU= MIME-Version: 1.0 Received: by 10.68.55.105 with SMTP id r9mr1922294pbp.504.1309406365185; Wed, 29 Jun 2011 20:59:25 -0700 (PDT) Received: by 10.68.51.65 with HTTP; Wed, 29 Jun 2011 20:59:25 -0700 (PDT) In-Reply-To: <4289.1308635599@sss.pgh.pa.us> References: <1308584339.2488.12.camel@dragflick> <4DFF27C5020000250003E9A4@gw.wicourts.gov> <1308585840.2488.13.camel@dragflick> <4DFF990F.8080906@fuzzy.cz> <1308623134.1747.1.camel@dragflick> <4289.1308635599@sss.pgh.pa.us> Date: Wed, 29 Jun 2011 20:59:25 -0700 Message-ID: Subject: Re: sequential scan unduly favored over text search gin index From: Jeff Janes To: Tom Lane Cc: sushant354@gmail.com, Tomas Vondra , pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001 X-Spam-Level: X-Archive-Number: 201106/274 X-Sequence-Number: 44207 On Mon, Jun 20, 2011 at 10:53 PM, Tom Lane wrote: > Sushant Sinha writes: >>> I guess you could poke the planner towards the bitmap scan by lowering >>> the random_page_cost (the default value is 4, I'd say lowering it to 2 >>> should do the trick). > >> The numbers that I gave was after setting random_page_cost =3D 1.0 After >> this I don't know what to do. > > I think part of the issue here is that the @@ operator is expensive, > and so evaluating it once per row is expensive, but the pg_proc.procost > setting for it doesn't adequately reflect that. =A0You could experiment > with tweaking that setting ... In something I was testing a couple months ago, by far the biggest expense of the @@ operator in a full table scan was in crawling through the entire toast table (and not necessarily in sequential order) in order to get the tsvector data on which to apply the operator. So increasing the cost of @@ might very well be the best immediate solution, but should the cost estimation code be changed to explicitly take page reads associated with toast into account, so that cost of @@ itself and can remain a CPU based estimate rather than an amalgam of CPU and IO? Cheers, Jeff