X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6B7443A4017 for ; Tue, 16 Nov 2004 20:58:46 +0000 (GMT) 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 92448-02 for ; Tue, 16 Nov 2004 20:58:30 +0000 (GMT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id 52C123A3F60 for ; Tue, 16 Nov 2004 20:58:32 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.200]) by svr4.postgresql.org (Postfix) with ESMTP id 8649F5AF736 for ; Tue, 16 Nov 2004 20:58:32 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id b11so823331rne for ; Tue, 16 Nov 2004 12:56:31 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=B3vSGRvDbM5v0KULXhTDPGTXRBjEqMU5n5qZeXPoUDyl88vEQn0ER5M/w5JlZhVbFjgodYh9+rkuiqTi3I4cL0ERcfZK7rV52rHGEhvlLoX5XRXzxUfYqVEKsHnzhNiP2+dGzxs+8cSyxanO+LA4zjX4OFrm589sUmIuEWqbgoA= Received: by 10.38.152.69 with SMTP id z69mr417903rnd; Tue, 16 Nov 2004 12:56:31 -0800 (PST) Received: by 10.38.165.32 with HTTP; Tue, 16 Nov 2004 12:56:31 -0800 (PST) Message-ID: <27c475ec04111612561a696fd1@mail.gmail.com> Date: Tue, 16 Nov 2004 15:56:31 -0500 From: Matt Nuzum Reply-To: matt@followers.net To: pgsql-sql@postgresql.org Subject: finding gaps in dates Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/158 X-Sequence-Number: 19477 I have a logging application that should produce an entry in the database every minute or so, give or take a few seconds. I'm interested in finding out a: what minutes don't have a record and b: periods where the gap exceeded a certain amount of time. The only way I can think of to do it is to create a set returning function that accepts a begin and end date and returns a date_trunc('minute', ...) for each minute between then and then doing Select ts from srf(now() - '30 days'::inteval, now()) where ts not in (select distinct date_trunc('minute', ts) from table where ts between now() - '30 days'::inteval and now()); Of course, that seems extremely tedious to me (not tedious to code, but tedious for the db to process). If anyone can suggest a better way I'd really appreciate it. -- Matthew Nuzum | Makers of "Elite Content Management System" www.followers.net | View samples of Elite CMS in action matt@followers.net | http://www.followers.net/portfolio/