Return-Path: <oracle-l-bounce@freelists.org>
Delivered-To: 2-oracle-l@orafaq.com
Received: (qmail 5698 invoked from network); 4 Apr 2007 03:00:26 -0500
Received: from freelists-180.iquest.net (HELO turing.freelists.org) (206.53.239.180)
  by 69.64.49.119 with SMTP; 4 Apr 2007 03:00:26 -0500
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 02D6B6982A7;
 Wed,  4 Apr 2007 03:58:54 -0400 (EDT)
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 11462-06; Wed, 4 Apr 2007 03:58:53 -0400 (EDT)
Received: from turing (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 6994069813C;
 Wed,  4 Apr 2007 03:58:53 -0400 (EDT)
Received: with ECARTIS (v1.0.0; list oracle-l); Wed, 04 Apr 2007 03:20:41 -0400 (EDT)
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 91F4F6993BD
 for <oracle-l@freelists.org>; Wed,  4 Apr 2007 03:20:41 -0400 (EDT)
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 08099-10 for <oracle-l@freelists.org>;
 Wed, 4 Apr 2007 03:20:41 -0400 (EDT)
Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.231])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 2B1C16993B5
 for <oracle-l@freelists.org>; Wed,  4 Apr 2007 03:20:05 -0400 (EDT)
Received: by wr-out-0506.google.com with SMTP id 60so85552wri
        for <oracle-l@freelists.org>; Wed, 04 Apr 2007 00:21:30 -0700 (PDT)
DKIM-Signature: a=rsa-sha1; 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:content-transfer-encoding:content-disposition:references;
        b=qgmhf0Xe4uMdJVN4+GhZ18bW5aTkN6BETLKb5+0RGZZbF8QLtSjsPw97HPl/nT8IiB2JV3VlXilKrJ3M5jtaZlQljdUzX6bhsgyxhEg0jIfgnxteNcICZpzbxrHWUuNkUdL62R0C6/EmV5R7GoOPDpbzbohBKPg2O/qKkZOaDSA=
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:content-transfer-encoding:content-disposition:references;
        b=fOkAw2jmEd32ay3tO1U8JT48AUHrLJrhwXcROvvhUE6WHLOv6INlmwF9dMO7FqhvMIuvFIDguf0XeQ4oQSBid4XVdoaROV6PdBEwzzjM/GcPJ5uyLkSe6lvzkRIVM8hFyJiabW0bOTeeUSwzfNi1qYECFJKVOteVZWLb30xHkjQ=
Received: by 10.114.15.1 with SMTP id 1mr112591wao.1175671290447;
        Wed, 04 Apr 2007 00:21:30 -0700 (PDT)
Received: by 10.115.106.4 with HTTP; Wed, 4 Apr 2007 00:21:30 -0700 (PDT)
Message-ID: <6e49b6d00704040021o23d2018cjba621f34d70cd77c@mail.gmail.com>
Date: Wed, 4 Apr 2007 10:21:30 +0300
From: "Gints Plivna" <gints.plivna@gmail.com>
To: andert@gmail.com
Subject: Re: Global (and local) Temporary Tables & PL/SQL
Cc: "oracle-l@freelists.org" <oracle-l@freelists.org>
In-Reply-To: <6d45e210704031329o13210352j8a7e0e248352e70d@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Disposition: inline
References: <6d45e210704031329o13210352j8a7e0e248352e70d@mail.gmail.com>
X-archive-position: 47422
X-ecartis-version: Ecartis v1.0.0
Sender: oracle-l-bounce@freelists.org
Errors-to: oracle-l-bounce@freelists.org
X-original-sender: gints.plivna@gmail.com
Precedence: normal
Reply-to: gints.plivna@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: by amavisd-new-20030616-p10 (Debian) at avenirtech.net

> table, it won't compile as the table is created and populated in the
> same step and thus does not exist when trying to compile the
> procedure.

So from thuis text I understood that table is being created at
runtime. I can only add my voice to the Tim's mail that GTT are not
predicted to use in the same way as temporary tables are for example
used in MS SQL Server. I won't explain much here why I don't like
dynamic SQL - the usual performance and code maintainability problems
apply.

>
> The facts known at this time are:
>
> 1. This table may be somewhat large (several hundred thousand rows
> with several VARCHAR 255 fields) at first, but later will be much more
> reasonable.

We have succesfully used both "explicit" GTTs (created manually) and
"implicit" GTTs (created by with clause of Selects). The only problem
I've encountered is quite obvious - if we create GTT using with clause
for select and later it use in some nested loops operation in the
select body, then if the GTT is big full scanning of it many times
becomes quite a pain :) Of course full scan of GTT some fixed number
of times (not dependant from number of rows) is absolutely normal.

>
> 2. Many users will be using this table at the same time with differing
> data and processing other data based on what they do with the data in
> these temp tables.

So this is somewhat contradictionary that you wrote before. If you you
are creating this temp table on the fly then it is very doubtful that
many users can use it - it is hard to imagine a scenario when you on
the fly create this table and all users just like after command starts
to use it and when it is dropped all of them stops to use it.
Obviously these will be several tables and each user will have his own
table.
Coincidentally just about a week ago I reviewed a code done by a
developer (obviously with MS background), here is what I got:
1) he created the GTT called T2 but later in procedure used table
called T1. So a wonderful example how it is hard to debug dynamic sql
and how he obviously had created table T1 manually - and what is more
important he succesfully used it! The create and drop scenario was
absolutely redundant.
2) it was much harder for me to go through the code because it simply
was dynamic sql.
3) if you create them on the fly depending on your user management
(either Oracle or application server users) you have to think how to
differentiate the names of them so that they are unique for a user or
not. And going further what if the same user connects more than once
in the same time? You need to differentiate it based even on some
session info or using some unique identifier. I personally wouldn't
like to think about such problems knowing I could easily avoid them
just creating one table. Also if your session dies you have in next
procedure run to check whether the table already is or isn't.
4) ddl on the fly will commit your transaction. It might be relevant
or might not be relevant to your app, but one has to remember that.

>
> The questions are:
>
> 2. Is there a way to "force" PL/SQL to "trust me, the table will be
> there" to get the proc to compile.

Just precreating them if you haven't too much very important reasons
not to do that, for example each time the structure of it may be
different and is not known in advance.

>
> 3. What else should I be thinking about that I am not (since I just
> got blind-sided with this).
Generally in terms of redo inserts are very very cheap for GTTs,
updates are much cheaper than for permanent tables, but deletes are
almost in the same level.

Gints Plivna
http://www.gplivna.eu
--
http://www.freelists.org/webpage/oracle-l


