Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 468959FB7C1 for ; Mon, 18 Jun 2007 02:55:02 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 63745-05 for ; Mon, 18 Jun 2007 02:54:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 62AFD9FB545 for ; Mon, 18 Jun 2007 02:54:58 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l5I5srL7002170; Mon, 18 Jun 2007 01:54:53 -0400 (EDT) To: Jeff Frost cc: pgsql-sql@postgresql.org Subject: Re: separating improperly grouped page views In-reply-to: References: Comments: In-reply-to Jeff Frost message dated "Sun, 17 Jun 2007 22:16:36 -0700" Date: Mon, 18 Jun 2007 01:54:53 -0400 Message-ID: <2169.1182146093@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/121 X-Sequence-Number: 28611 Jeff Frost writes: > [ umpteen million iterations of: ] > -> Limit (cost=0.00..367.09 rows=1 width=8) > -> Index Scan Backward using page_view_stamp_idx on page_view pv2 (cost=0.00..158215.86 rows=431 width=8) > Index Cond: (stamp < $1) > Filter: ((stamp IS NOT NULL) AND (visit_id = $0)) Perhaps an index on (visit_id, stamp) would help. This one is doing the best it can, but if the visit_id's you want are thinly scattered, it'll still suck... regards, tom lane