Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Select count(*) in Oracle and MySQL

Re: Select count(*) in Oracle and MySQL

From: <joeNOSPAM_at_BEA.com>
Date: Wed, 19 Sep 2007 22:46:27 -0000
Message-ID: <1190241987.806097.231690@k35g2000prh.googlegroups.com>


On Sep 19, 11:40 am, Occidental <Occiden..._at_comcast.net> wrote:
> I have a table with about 250M rows, implemented in both Oracle and
> MySQL.
> Select count(*) in MySQL is effectively instantaneous, presumably
> because it accesses some internal count that is maintained by the
> DBMS. The same query in Oracle takes about 6 minutes, pretty obviously
> becasue it counts rows. The Oracle table should have been set up with
> a primary key, but wasn't. The MySQL table has no primary key either.
> Any comments?

    In the commercial-strength high-throughput environment Oracle is designed for, the answer to the question "select count(*) from MyHugeTable" is typically useless, and asking it, especially for a table of that size, is indicative of a gross problem looming in your application. Unless you are raising the architectural error by a factor
of ten, by adding " FOR UPDATE", the answer you get could be be stale and inaccurate in the milliseconds between it's having been calculated and when that number is sent to you. Received on Wed Sep 19 2007 - 17:46:27 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US