Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 447579FB32D for ; Tue, 22 May 2007 06:42:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 59757-08 for ; Tue, 22 May 2007 06:42:20 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id 2D0E99FA2F4 for ; Tue, 22 May 2007 06:42:20 -0300 (ADT) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id C425474EE2; Tue, 22 May 2007 10:42:18 +0100 (BST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 0F3F3274115; Tue, 22 May 2007 10:42:20 +0100 (BST) Message-ID: <4652BAFA.5060206@archonet.com> Date: Tue, 22 May 2007 10:42:18 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: Joost Kraaijeveld Cc: pgsql-performance@postgresql.org Subject: Re: is file size relevant in choosing index or table scan? References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/425 X-Sequence-Number: 24815 Joost Kraaijeveld wrote: > Hi, > > I have a table with a file size of 400 MB with an index of 100 MB. > Does PostgreSQL take the file sizes of both the table and the index > into account when determing if it should do a table or an index scan? In effect yes, although it will think in terms of row sizes and disk blocks. It also considers how many rows it thinks it will fetch and whether the rows it wants are together or spread amongst many blocks. It also tries to estimate what the chances are of those blocks being cached in RAM vs still on disk. So: 1 row from a 4 million row table, accessed by primary key => index. 20 rows from a 200 row table => seq scan (probably). In between => depends on your postgresql.conf -- Richard Huxton Archonet Ltd