X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 93E8FD6EA8 for ; Tue, 23 Aug 2005 06:06:50 -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 94830-05 for ; Tue, 23 Aug 2005 09:06:45 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id D0565D6ECE for ; Tue, 23 Aug 2005 06:06:44 -0300 (ADT) Received: (qmail 23391 invoked from network); 23 Aug 2005 11:07:07 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 23 Aug 2005 11:07:07 +0200 Date: Tue, 23 Aug 2005 11:06:42 +0200 To: "Gary Stainburn" , pgsql-sql@postgresql.org Subject: Re: diary constraints References: <200508230933.59043.gary.stainburn@ringways.co.uk> From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <200508230933.59043.gary.stainburn@ringways.co.uk> User-Agent: Opera M2/8.0 (Linux, build 1095) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200508/201 X-Sequence-Number: 22429 > a) the finish is after the start well, finish > start > b) two allocations for a single vehicle don't overlap. this one is a bit tricky ! - Check that there is no allocation in the table whose time period start, end includes either the start of the end of the reservation to insert, and that the time period of the reservation to insert does not contain either the start or end of any reservation in the table. This is 4 selects, playing with order by limit 1 and indexes, it will be fast.