Links
Home
Oracle DBA Forum
Frequent Oracle Errors
TNS:could not resolve the connect identifier specified
Backtrace message unwound by exceptions
invalid identifier
PL/SQL compilation error
internal error
missing expression
table or view does not exist
end-of-file on communication channel
TNS:listener unknown in connect descriptor
insufficient privileges
PL/SQL: numeric or value error string
TNS:protocol adapter error
ORACLE not available
target host or object does not exist
invalid number
unable to allocate string bytes of shared memory
resource busy and acquire with NOWAIT specified
error occurred at recursive SQL level string
ORACLE initialization or shutdown in progress
archiver error. Connect internal only, until freed
snapshot too old
unable to extend temp segment by string in tablespace
Credential retrieval failed
missing or invalid option
invalid username/password; logon denied
unable to create INITIAL extent for segment
out of process memory when trying to allocate string bytes
shared memory realm does not exist
cannot insert NULL
TNS:unable to connect to destination
remote database not found'>ora-02019
exception encountered: core dump
inconsistent datatypes
no data found
TNS:operation timed out
PL/SQL: could not find program
existing state of packages has been discarded
maximum number of processes exceeded
error signaled in parallel query server
ORACLE instance terminated. Disconnection forced
TNS:packet writer failure
see ORA-12699
missing right parenthesis
name is already used by an existing object
cannot identify/lock data file
invalid file operation
quoted string not properly terminated
is it possible in pl/sql?

is it possible in pl/sql?

2005-02-10       - By Mercadante, Thomas F

Reply:     1     2     3     4     5     6     7     8     9     10     >>  

David,

Just try running an explain plan against your select count statement.  Run
it against a table with a primary key, and one without one.  Run it against
a table with a unique key but no primary key.

What you will find is that Oracle will pick the quickest way to get the
result.  If there is a PK or Unique Key, it will scan the index - because
the column is NOT NULL, it will have an entry for every row.

If the table does not have any unique index to use, it will count the rows
in the table.

Tom

-- --Original Message-- --
From: david wendelken [mailto:davewendelken@(protected)]
Sent: Thursday, February 10, 2005 9:05 AM
To: oracle-l@(protected)
Subject: Re: is it possible in pl/sql?


It's always good to have folks challenge your beliefs - helps one to grow!

It would never have occurred to me to count the number of reads - because
the same number of rows would have to be read either way.

Where I believed the efficiency to come in was in the internals of the
processing of the count function.

In other contexts, * means "all the columns returned by the query".
A reasonable extrapolation in this case would mean "the values of all the
columns returned by the query".

Since count does not increment it's internal counter when the value passed
to it is null, it made sense to believe that the count function had to check
the values returned to verify whether a non-null value had been passed to
it.

Therefore, it made sense to expect it to have to parse (via if-statement
logic) thru the values to determine whether the aggregate value was null.
I/O wouldn't be longer but more cpu time would be required.

This morning, I tested count(*) against a table that had a row comprised
solely of null values and that row was counted.  (Never tested that before
as I've never thought of a reason to have a table like that!)

Checked the manual, and it is treating the * as a special character, not as
I believed.

So, you guys are right on that point!  Thanks.





--
http://www.freelists.org/webpage/oracle-l
--
http://www.freelists.org/webpage/oracle-l