Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 8AC3D2E3599 for ; Tue, 5 Feb 2008 07:47:52 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 90193-02 for ; Tue, 5 Feb 2008 07:47:34 -0400 (AST) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.186]) by postgresql.org (Postfix) with ESMTP id 5592C2E394B for ; Tue, 5 Feb 2008 07:47:49 -0400 (AST) Received: by fk-out-0910.google.com with SMTP id b27so2725322fka.3 for ; Tue, 05 Feb 2008 03:47:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=nVNIW1qcONW1IxzmZ+wR28E5TP1BiEx2QPi4cCQfP/Q=; b=O6r3OiDIwcvZaTTbThgQe3dWCz4ziTryEA3/+x9jG9o9LhBAdPp6W8ul4A91tBkQ4dhY+W5ZJq5/OFy5A+I/WatTSEwJ9+aWREb4zOptUeXfobxj3WBYtNBIxCeJQcEXHOjr3FNLL/rl8edjk7y6THJkDnsTuE7vLYo8R91JVM4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=G4NN2mErAi1BqYdwcSMEUhkoPxiypP86kXfNu0Pf96AJNb+YcjpnYtxiOFMU8zBsIn4mRQId+/1f5V5QyoMF3CFl9kwTfM5qNsS8+2aTmLw0rfUrnn4DAFfpQaMj5kSrpfixa69zfeb1pTxoUNS73qnEZa5L1p+SWhVTGKSufaA= Received: by 10.82.138.6 with SMTP id l6mr15243554bud.13.1202212067430; Tue, 05 Feb 2008 03:47:47 -0800 (PST) Received: by 10.82.127.17 with HTTP; Tue, 5 Feb 2008 03:47:47 -0800 (PST) Message-ID: Date: Tue, 5 Feb 2008 12:47:47 +0100 From: "Viviane Lestic" To: pgsql-performance@postgresql.org Subject: Performance issue using Tsearch2 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200802/26 X-Sequence-Number: 28568 Hi, I'm having a performance problem on a request using Tsearch2: the request strangely takes several minutes. I've tried to follow Tsearch tuning recommendations, I've searched through the archives, but I can't seem to find a solution to solve my problem. The ts_vector field was created using dictionnary fr_ispell only on types lword, lpart_hword and lhword. An index was created on this field. According to the stat() function, there are only 42,590 word stems indexed. I also did a VACUUM FULL ANALYZE. Here's the result of EXPLAIN ANALYZE on a filtered version of my request (the non-filtered version takes so long I usually cancel it): ************************************************************************** explain analyze SELECT idstruct, headline(zonetext, q), rank(zoneindex_test, q) FROM tab_ocr, tab_chemin, to_tsquery('partir') AS q WHERE tab_chemin.chemin like '%;2;%' AND tab_ocr.idstruct = tab_chemin.label AND zoneindex_test @@ q ORDER BY rank(zoneindex_test, q) DESC; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=2345.54..2345.58 rows=16 width=308) (actual time=270638.774..270643.142 rows=7106 loops=1) Sort Key: rank(tab_ocr.zoneindex_test, q.q) -> Nested Loop (cost=80.04..2345.22 rows=16 width=308) (actual time=40886.553..270619.730 rows=7106 loops=1) -> Nested Loop (cost=80.04..1465.76 rows=392 width=308) (actual time=38209.193..173932.313 rows=272414 loops=1) -> Function Scan on q (cost=0.00..0.01 rows=1 width=32) (actual time=0.006..0.007 rows=1 loops=1) -> Bitmap Heap Scan on tab_ocr (cost=80.04..1460.85 rows=392 width=276) (actual time=38209.180..173507.052 rows=272414 loops=1) Filter: (tab_ocr.zoneindex_test @@ q.q) -> Bitmap Index Scan on zoneindex_test_idx (cost=0.00..79.94 rows=392 width=0) (actual time=38204.261..38204.261 rows=283606 loops=1) Index Cond: (tab_ocr.zoneindex_test @@ q.q) -> Index Scan using tab_chemin_label_index on tab_chemin (cost=0.00..2.23 rows=1 width=4) (actual time=0.036..0.036 rows=0 loops=272414) Index Cond: (tab_ocr.idstruct = tab_chemin.label) Filter: ((chemin)::text ~~ '%;2;%'::text) Total runtime: 270647.946 ms ************************************************************************** Could someone help me analyze this problem? I don't manage to see if the problem comes from bad tsearch tuning, postgresql configuration, or something else... Thanks.