Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TCAoC-0000jC-6L for pgsql-performance@postgresql.org; Thu, 13 Sep 2012 14:54:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TCAoA-00079x-TB for pgsql-performance@postgresql.org; Thu, 13 Sep 2012 14:54:23 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q8DEsJBA026907; Thu, 13 Sep 2012 10:54:19 -0400 (EDT) From: Tom Lane To: Jesper Krogh cc: Bill Martin , "pgsql-performance@postgresql.org" Subject: Re: Planner selects different execution plans depending on limit In-reply-to: <5051F227.7090600@krogh.cc> References: <5051F227.7090600@krogh.cc> Comments: In-reply-to Jesper Krogh message dated "Thu, 13 Sep 2012 16:48:07 +0200" Date: Thu, 13 Sep 2012 10:54:19 -0400 Message-ID: <26906.1347548059@sss.pgh.pa.us> X-Pg-Spam-Score: -2.4 (--) X-Archive-Number: 201209/55 X-Sequence-Number: 47801 Jesper Krogh writes: > On 13/09/12 16:42, Bill Martin wrote: >> Yes, I've run the ANALYZE command. Regards, Bill Martin > The main problem in your case is actually that you dont store the > tsvector in the table. Oh, duh, obviously I lack caffeine this morning. > If you store to_tsvector('simple',content.content) in a column in > the database and search against that instead > then you'll allow PG to garther statistics on the column and make the > query-planner act according to that. He can do it without having to change his schema --- but it's the index column, not the underlying content column, that needs its statistics target adjusted. regards, tom lane