X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5277B528A8 for ; Wed, 22 Jun 2005 06:36:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68252-08 for ; Wed, 22 Jun 2005 09:36:53 +0000 (GMT) Received: from exobox.exoweb.net (unknown [221.122.43.98]) by svr1.postgresql.org (Postfix) with SMTP id 23CE952886 for ; Wed, 22 Jun 2005 06:36:45 -0300 (ADT) Received: (qmail 31153 invoked from network); 22 Jun 2005 09:36:44 -0000 Received: from exo185.exoweb.net (HELO tobias.nordicbet.invalid) (192.168.0.185) by 0 with SMTP; 22 Jun 2005 09:36:44 -0000 Received: by tobias.nordicbet.invalid (Postfix, from userid 500) id 6EA79E0D07; Wed, 22 Jun 2005 17:36:44 +0800 (CST) Date: Wed, 22 Jun 2005 17:36:44 +0800 From: Tobias Brox To: Kjell Tore Fossbakk Cc: Michael Glaesemann , Tobias Brox , pgsql-performance@postgresql.org Subject: Re: Querying 19million records very slowly Message-ID: <20050622093644.GA7839@tobias> References: <42B8719A.6040809@refractions.net> <20050622080357.GW7839@tobias> <20050622083921.GZ7839@tobias> <8B2836FF-F335-49A4-8131-8EF2D02100F9@myrealbox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Group Nordicbet User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200506/431 X-Sequence-Number: 13068 [Kjell Tore Fossbakk - Wed at 11:10:42AM +0200] > Which one does Pg read fastes? Does he convert datetime in the table, > then my where clause and check, for each row? How does he compare a > datetime with a datetime? Timestamp are easy, large number bigger than > another large number.. > > time (datetime) > '2005-06-21 10:36:22+02' > > or > > time (timestamp) > 'some timestamp pointing to yesterday' If I have understood it correctly, the planner will recognize the timestamp and compare it with the statistics in the first example but not in the second, and thus it will be more likely to use index scan on the first one and seqscan on the second. -- Tobias Brox, +86-13521622905 Nordicbet, IT dept