Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 68FCF2E0060 for ; Tue, 17 Jun 2008 10:14:17 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 52971-03-7 for ; Tue, 17 Jun 2008 10:14:00 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ppsw-1.csi.cam.ac.uk (ppsw-1.csi.cam.ac.uk [131.111.8.131]) by developer.postgresql.org (Postfix) with ESMTP id 55E682E002E for ; Tue, 17 Jun 2008 10:13:40 -0300 (ADT) X-Cam-SpamDetails: Not scanned X-Cam-AntiVirus: No virus found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from flymine.sysbiol.cam.ac.uk ([131.111.60.120]:50256 helo=flymine.flymine.org) by ppsw-1.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.131]:25) with esmtp id 1K8b04-00010X-3m (Exim 4.67) for pgsql-performance@postgresql.org (return-path ); Tue, 17 Jun 2008 14:13:28 +0100 Received: from host103 ([192.168.128.103] helo=aragorn.flymine.org ident=Debian-exim) by flymine.flymine.org with esmtp (Exim 4.12) id 1K8b04-0005GP-00 for pgsql-performance@postgresql.org; Tue, 17 Jun 2008 14:13:28 +0100 Received: from mnw21 (helo=localhost) by aragorn.flymine.org with local-esmtp (Exim 4.69) (envelope-from ) id 1K8b03-0005L8-P0 for pgsql-performance@postgresql.org; Tue, 17 Jun 2008 14:13:27 +0100 Date: Tue, 17 Jun 2008 14:13:27 +0100 (BST) From: Matthew Wakeling X-X-Sender: mnw21@aragorn.flymine.org To: pgsql-performance@postgresql.org Subject: Re: Tsearch2 Initial Search Speed In-Reply-To: <4857A739.5020800@selestial.com> Message-ID: References: <4856A91F.1020001@selestial.com> <200806161124.57543@hal.medialogik.com> <485789C1.3000803@selestial.com> <485797D4.7010201@selestial.com> <48579EB1.8050403@selestial.com> <4857A739.5020800@selestial.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200806/66 X-Sequence-Number: 30416 On Tue, 17 Jun 2008, Howard Cole wrote: > If I do a query that uses another index, then it uses the index only and > does not scan the email table. Not true. It only looks a little bit like that from the explain output. However, if you look closely: > Index Scan using email_email_directory_id_idx on email (cost=0.00..129.01 rows=35 width=8) > Index Cond: (email_directory_id = 1) > (2 rows) It's a scan *using* the index, but *on* the table "email". This index scan is having to read the email table too. > The scan on the fts index takes 6 seconds, which presumably returns > email_id's (the email_id being the primary key) - what does it then need > from the email table that takes 22 seconds? Actually, the index returns page numbers in the table on disc which may contain one or more rows that are relevant. Postgres has to fetch the whole row to find out the email_id and any other information, including whether the row is visible in your current transaction (concurrency control complicates it all). Just having a page number isn't much use to you! Matthew -- First law of computing: Anything can go wro sig: Segmentation fault. core dumped.