Unless you do something to force it, Oracle doesn't actually describe the
statement (fetch table and column information from the database) until
execute() time.  Then it also normally fetches the first buffer full of rows
which can be very expensive for large tables.

A "SELECT * FROM table" may be the easiest way to test for a table's
existence, but it's much safer and probably cheaper to check the data
dictionary of whatever database you are using.  I'd at least add a WHERE
clause that guarantees no rows get fetched like 'WHERE 1 = 2'.
--
Mac :})
** I normally forward private database questions to the DBI mail lists. **
Give a hobbit a fish and he'll eat fish for a day.
Give a hobbit a ring and he'll eat fish for an age.
----- Original Message -----
From: "Neil Lunn" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 30, 2001 5:33 PM
Subject: RE: Easiest way to tell if a table already exists?


> > -----Original Message-----
> > From: PD Miller [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, April 30, 2001 6:31 PM
> > To: Sterin, Ilya; Mike Schienle; [EMAIL PROTECTED]
> > Subject: RE: Easiest way to tell if a table already exists?
> >
> >
> > At 21:56 -0400 25/4/01, Sterin, Ilya wrote:
> > >Why would (select * from foo) take up lost of resources?
> > Won't it just
> > >place the cursor at the first row and only return when rows
> > are fetched?
> >
> > Speaking for Oracle, as soon as the statement is executed (and before
> > any fetch) Oracle will execute the statement - and that means
> > performing the full table scan(s) or index scan(s) necessary to
> > fulfill the statement.
>
> You missed the point. This all happens at the prepare with little cost.
That
> is what prepare is for.


Reply via email to