Return-Path: <oracle-l-bounce@freelists.org>
Delivered-To: 2-oracle-l@orafaq.com
Received: (qmail 15266 invoked from network); 20 Sep 2007 13:23:16 -0500
Received: from freelists-180.iquest.net (HELO turing.freelists.org) (206.53.239.180)
  by 69.64.49.119 with SMTP; 20 Sep 2007 13:23:11 -0500
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id B59F2760D5A;
 Thu, 20 Sep 2007 14:23:02 -0400 (EDT)
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 06635-01; Thu, 20 Sep 2007 14:23:02 -0400 (EDT)
Received: from turing (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 19221760C22;
 Thu, 20 Sep 2007 14:23:02 -0400 (EDT)
Received: with ECARTIS (v1.0.0; list oracle-l); Thu, 20 Sep 2007 13:37:33 -0400 (EDT)
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 70ECE760FAD
 for <oracle-l@freelists.org>; Thu, 20 Sep 2007 13:37:33 -0400 (EDT)
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 30843-06 for <oracle-l@freelists.org>;
 Thu, 20 Sep 2007 13:37:33 -0400 (EDT)
Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.226])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 251D6760FC6
 for <oracle-l@freelists.org>; Thu, 20 Sep 2007 13:37:32 -0400 (EDT)
Received: by nz-out-0506.google.com with SMTP id s18so495409nze
        for <oracle-l@freelists.org>; Thu, 20 Sep 2007 10:37:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=beta;
        h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references;
        bh=qxArp3+NdfAgJYWwCtg6gWxh7DnCvp2ZB4UZIrEYJiA=;
        b=BW+RpK4qxyedmPkmaCbiIpSTHE7yPqzZuBacEt7SHZy7Hj88D2FSlxRUPQIwtyhCiSbCi9SBRSIo6lAlvfYgOuN6zzTTzlOK2P/a1hHOYnVVjXUBppzPNGfwuwgf8RjqEfcCalr0LmsrVq3aBJq5JQln+NusRHbQyqcDYCuo5Ko=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=beta;
        h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references;
        b=SsDa+UC48aKoScN+jvgbtufa6xZ1xYh+VUUc7ko+HM8EyQTUIGJx5rikpTBjiRyt13LjB03/WF2H2st70CEH3n4tHr+9XUXm2MzNHq611dTv1zfJlbdC9OOgayQZZT+yIOgGov620qqwS65hxDK1kSgvJGBfAOnfHZK+uE8gxIw=
Received: by 10.142.231.7 with SMTP id d7mr922085wfh.1190309851749;
        Thu, 20 Sep 2007 10:37:31 -0700 (PDT)
Received: by 10.143.39.20 with HTTP; Thu, 20 Sep 2007 10:37:31 -0700 (PDT)
Message-ID: <9c9b9dc90709201037o18a47b8dt58a85b1746fcd5f7@mail.gmail.com>
Date: Thu, 20 Sep 2007 13:37:31 -0400
From: "Rumpi Gravenstein" <rgravens@gmail.com>
To: nigel_cl_thomas@yahoo.com
Subject: Re: am I reading this SQL correctly?
Cc: genegurevich@discover.com, oracle-l <oracle-l@freelists.org>
In-Reply-To: <888447.42589.qm@web58712.mail.re1.yahoo.com>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----=_Part_27153_23420195.1190309851734"
References: <888447.42589.qm@web58712.mail.re1.yahoo.com>
X-archive-position: 1770
X-ecartis-version: Ecartis v1.0.0
Sender: oracle-l-bounce@freelists.org
Errors-to: oracle-l-bounce@freelists.org
X-original-sender: rgravens@gmail.com
Precedence: normal
Reply-to: rgravens@gmail.com
List-help: <mailto:ecartis@freelists.org?Subject=help>
List-unsubscribe: <oracle-l-request@freelists.org?Subject=unsubscribe>
List-software: Ecartis version 1.0.0
List-Id: oracle-l <oracle-l.freelists.org>
X-List-ID: oracle-l <oracle-l.freelists.org>
List-subscribe: <oracle-l-request@freelists.org?Subject=subscribe>
List-owner: <mailto:steve.adams@ixora.com.au>
List-post: <mailto:oracle-l@freelists.org>
List-archive: <http://www.freelists.org/archives/oracle-l>
X-list: oracle-l
X-Virus-Scanned: Debian amavisd-new at localhost.localdomain
------=_Part_27153_23420195.1190309851734
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

One issue that Nigel hasn't addressed is that you will want to account for a
call overlapping with itself.  That might be done with something along the
lines of:

a.ROWID != b.ROWID

On 9/20/07, Nigel Thomas <nigel_cl_thomas@yahoo.com> wrote:
>
> Gene
>
> 1) How is the "current call" identified? - this query will report ANY
> calls that overlap (where call A starts during call B) - even if both calls
> are way in the past.
> 2) It could be restated as a.CALL_START_TS between B.CALL_START_TS and
> B.CALL_END_TS - which could be a range scan (in a nested loop)  but B has
> no predicates. Still unpleasant!
> 3) Why doesn't it check for B starting during A
> 4) Why doesn't it check for B completely overlapping A (B starts before
> and finishes after A) and vice versa
>
> You have identified:
> A:  ----  |   --    |  ----  |     ----
> B:----    | ------  |  ----  | ----
>
> but not other variants eg
>
> A:----    | ------  | ----
> B:  ----  |   ---   |     ----
>
> (view in a monotype font or this will look silly)
>
> 5) In a procedural loop (within a pipeline function) I think you could do
> this in a single pass (ordered by CALL_START_TS)
> start with an empty in memory collection of calls (start time, end time,
> overlap count)
> for all records
> - read a record
> - increment overlap count for all collected calls that overlap with this
> one
> - register its start time and end time (into the collection in memory)
> (with the total overlap count just calculated)
> - report (eg by emitting a row from the pipelined function) all calls in
> the collection with an end time prior to the current record's start (don't
> include records with no overlaps)
> - and remove those records from the register
> At the end of the loop, emit all remaining records with overlap count > 0
> (possibly grouping by call_start_ts - as several calls could start
> simultaneously I presume)
>
> Having described that, is it possible to do the same with a analytic
> functions (eg WINDOW)?
>
> HTH
>
> Regards Nigel
>
> ----- Original Message ----
> From: "genegurevich@discover.com" genegurevich@discover.com
>
> I am trying to tune the following SQL (in 10.2.0.3)
>
> SELECT a.CALL_STRT_TS, count(b.Call_STRT_TS)
> from IVR.IVC_IVR_CMS_CALL  a, IVR.IVC_IVR_CMS_CALL
> where a.CALL_STRT_TS >= b.CALL_STRT_TS
>    and a.CALL_STRT_TS <= b.CALL_END_TS
> group by a.CALL_STRT_TS;
>
> The goal of this is  to count the number of calls that overlap timewise
> with a current call.
> --
> http://www.freelists.org/webpage/oracle-l
>
>
>


-- 
Rumpi Gravenstein

------=_Part_27153_23420195.1190309851734
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div>One issue that Nigel hasn&#39;t addressed is that you will want to account for a call overlapping with itself.&nbsp; That might be done with something along the lines of:</div>
<div>&nbsp;</div>
<div>a.ROWID != b.ROWID <br>&nbsp;</div>
<div><span class="gmail_quote">On 9/20/07, <b class="gmail_sendername">Nigel Thomas</b> &lt;<a href="mailto:nigel_cl_thomas@yahoo.com">nigel_cl_thomas@yahoo.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Gene<br><br>1) How is the &quot;current call&quot; identified? - this query will report ANY calls that overlap (where call A starts during call B) - even if both calls are way in the past.
<br>2) It could be restated as a.CALL_START_TS between B.CALL_START_TS and B.CALL_END_TS - which could be a range scan (in a nested loop)&nbsp;&nbsp;but B has no predicates. Still unpleasant!<br>3) Why doesn&#39;t it check for B starting during A
<br>4) Why doesn&#39;t it check for B completely overlapping A (B starts before and finishes after A) and vice versa<br><br>You have identified:<br>A:&nbsp;&nbsp;----&nbsp;&nbsp;|&nbsp;&nbsp; --&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;----&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp; ----<br>B:----&nbsp;&nbsp;&nbsp;&nbsp;| ------&nbsp;&nbsp;|&nbsp;&nbsp;----&nbsp;&nbsp;| ----
<br><br>but not other variants eg<br><br>A:----&nbsp;&nbsp;&nbsp;&nbsp;| ------&nbsp;&nbsp;| ----<br>B:&nbsp;&nbsp;----&nbsp;&nbsp;|&nbsp;&nbsp; ---&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; ----<br><br>(view in a monotype font or this will look silly)<br><br>5) In a procedural loop (within a pipeline function) I think you could do this in a single pass (ordered by CALL_START_TS)
<br>start with an empty in memory collection of calls (start time, end time, overlap count)<br>for all records<br>- read a record<br>- increment overlap count for all collected calls that overlap with this one<br>- register its start time and end time (into the collection in memory) (with the total overlap count just calculated)
<br>- report (eg by emitting a row from the pipelined function) all calls in the collection with an end time prior to the current record&#39;s start (don&#39;t include records with no overlaps)<br>- and remove those records from the register
<br>At the end of the loop, emit all remaining records with overlap count &gt; 0 (possibly grouping by call_start_ts - as several calls could start simultaneously I presume)<br><br>Having described that, is it possible to do the same with a analytic functions (eg WINDOW)?
<br><br>HTH<br><br>Regards Nigel<br><br>----- Original Message ----<br>From: &quot;<a href="mailto:genegurevich@discover.com">genegurevich@discover.com</a>&quot; <a href="mailto:genegurevich@discover.com">genegurevich@discover.com
</a><br><br>I am trying to tune the following SQL (in <a href="http://10.2.0.3">10.2.0.3</a>)<br><br>SELECT a.CALL_STRT_TS, count(b.Call_STRT_TS)<br>from IVR.IVC_IVR_CMS_CALL&nbsp;&nbsp;a, IVR.IVC_IVR_CMS_CALL<br>where a.CALL_STRT_TS
 &gt;= b.CALL_STRT_TS<br>&nbsp;&nbsp; and a.CALL_STRT_TS &lt;= b.CALL_END_TS<br>group by a.CALL_STRT_TS;<br><br>The goal of this is&nbsp;&nbsp;to count the number of calls that overlap timewise<br>with a current call.<br>--<br><a href="http://www.freelists.org/webpage/oracle-l">
http://www.freelists.org/webpage/oracle-l</a><br><br><br></blockquote></div><br><br clear="all"><br>-- <br>Rumpi Gravenstein 

------=_Part_27153_23420195.1190309851734--
--
http://www.freelists.org/webpage/oracle-l


