Re: Count(*)ing nested tables
- From: "John Currier" <md4curvs@xxxxxxxxx>
- Date: 26 Jul 2005 07:00:24 -0700
> When you mention * in the select-list of a table with nest tables, it
> tries to expand all the fields in nested table(s) too, which results in
> a messy multi-dimensional result set for each row, and seems to be
> ambiguous in the context of COUNT().
>
> I don't have any direct experience with nested tables, but I'm supposing
> that you could try "SELECT COUNT(1) FROM WHATEVER". That should be a
> non-NULL value for each row of the non-nested table, without attempting
> to reference any of the nested tables within it. The value of 1 is
> arbitrary; any other non-NULL constant value would work equally well,
> since we're only counting them.
>
> You could probably also do COUNT(pk) where pk is the name of a non-NULL
> column in the table. But for when you don't know the name of a non-NULL
> column (if any exists), stick with COUNT(1).
Interesting. Your comments are making me think about how to optimize
that select.
So, what's the most efficient way to get the number of rows in an
arbitrary table, given that I know the primary key and index details?
Thanks,
John
http://schemaspy.sourceforge.net
.
- Follow-Ups:
- Re: Count(*)ing nested tables
- From: Jim Kennedy
- Re: Count(*)ing nested tables
- References:
- Count(*)ing nested tables
- From: John Currier
- Re: Count(*)ing nested tables
- From: Bill Karwin
- Count(*)ing nested tables
- Prev by Date: Re: Count(*)ing nested tables
- Next by Date: Re: Count(*)ing nested tables
- Previous by thread: Re: Count(*)ing nested tables
- Next by thread: Re: Count(*)ing nested tables
- Index(es):
Relevant Pages
|