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 ACFE053A24 for ; Sat, 2 Apr 2005 00:24:13 +0100 (BST) 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 90989-06 for ; Fri, 1 Apr 2005 23:24:04 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 940CA53A04 for ; Sat, 2 Apr 2005 00:24:02 +0100 (BST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j31NO2H8005789 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 1 Apr 2005 16:24:04 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j31NO2Du008465; Fri, 1 Apr 2005 16:24:02 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j31NO1OG008464; Fri, 1 Apr 2005 16:24:01 -0700 (MST) (envelope-from mfuhr) Date: Fri, 1 Apr 2005 16:24:01 -0700 From: Michael Fuhr To: "H.J. Sanders" Cc: pgsql-performance@postgresql.org Subject: Re: date - range Message-ID: <20050401232401.GA8389@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/26 X-Sequence-Number: 11423 On Fri, Apr 01, 2005 at 12:05:44PM +0200, H.J. Sanders wrote: > > people can subscribe to a service for 1 or more days (upto a max. of 365). > > So in the database is stored: first_date and last_date > > To select which people are subscribed for a certain date (e.g. today) we use > a select like > > select ....... where first_date <= today and last_date >= today > > Whatever index we create system always does a sequential scan (which I can > understand). Could you show the table and index definitions and the EXPLAIN ANALYZE output of two queries, one with enable_seqscan set to "on" and one with it set to "off"? The planner might think that a sequential scan would be faster than an index scan, and EXPLAIN ANALYZE should tell us if that guess is correct. What version of PostgreSQL are you using? -- Michael Fuhr http://www.fuhr.org/~mfuhr/