Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VGkzp-00063j-Ig for pgsql-performance@arkaria.postgresql.org; Tue, 03 Sep 2013 07:25:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VGkzo-0001qj-TI for pgsql-performance@arkaria.postgresql.org; Tue, 03 Sep 2013 07:25:52 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VGkzo-0001qd-0B for pgsql-performance@postgresql.org; Tue, 03 Sep 2013 07:25:52 +0000 Received: from 2605ds1-ynoe.3.fullrate.dk ([90.185.142.83] helo=shrek.krogh.cc) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VGkzh-0002t2-11 for pgsql-performance@postgresql.org; Tue, 03 Sep 2013 07:25:51 +0000 Received: from localhost (localhost [127.0.0.1]) by shrek.krogh.cc (Postfix) with ESMTP id 48141346013 for ; Tue, 3 Sep 2013 09:46:05 +0200 (CEST) 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 rSDLHDvCmdCV for ; Tue, 3 Sep 2013 09:46:02 +0200 (CEST) Received: from shrek.krogh.cc (localhost [127.0.0.1]) by shrek.krogh.cc (Postfix) with ESMTP id 42FE7345FE9 for ; Tue, 3 Sep 2013 09:46:02 +0200 (CEST) Received: from 94.101.220.16 (SquirrelMail authenticated user jesper@krogh.cc) by shrek.krogh.cc with HTTP; Tue, 3 Sep 2013 09:46:02 +0200 (CEST) Message-ID: Date: Tue, 3 Sep 2013 09:46:02 +0200 (CEST) Subject: Slow query-plan generation (fast query) PG 9.2 From: jesper@krogh.cc To: pgsql-performance@postgresql.org User-Agent: SquirrelMail/1.4.15 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Hi. I have a strange situation where generating the query plan takes 6s+ and executing it takes very little time. 2013-09-03 09:19:38.726 db=# explain select table.id from db.table left join db.tablepro on db.id = tablepro.table_id where table.fts @@ to_tsquery('english','q12345') ; QUERY PLAN ------------------------------------------------------------------------------------------------------------------- Nested Loop Left Join (cost=43.71..12711.39 rows=2930 width=4) -> Bitmap Heap Scan on sequence (cost=43.71..4449.10 rows=2930 width=4) Recheck Cond: (fts @@ '''q12345'''::tsquery) -> Bitmap Index Scan on table_gin_idx (cost=0.00..42.98 rows=2930 width=0) Index Cond: (fts @@ '''q12345'''::tsquery) -> Index Only Scan using tablepro_seqid_idx on tablepro (cost=0.00..2.81 rows=1 width=4) Index Cond: (tablepro_id = table.id) (7 rows) Time: 10458.404 ms The query gives 4 rows out of 50.000.000, so the query-plan is actually correct and as expected. Any suggestions? Jesper -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance