Re: Count(*)ing nested tables



> 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

.



Relevant Pages

  • Re: [PATCH 14/18] 2.6.17.9 perfmon2 patch for review: new i386 files
    ... counting when you go low-power. ... the idle may be doing useful kernel work, ... I think I am not so clear on the intended usage user ... done each time a context is created, or each time a context is actually ...
    (Linux-Kernel)
  • Re: Albanian seems odd
    ... My suspicion is that the number words, being often chanted in counting ... (where context is unusually powerful in fixing the meaning) ...
    (sci.lang)
  • Re: [PATCH]: Fix regression added by ppoll/pselect code.
    ... Yeah, but so does the context. ... > b) Ever tried counting nine contiguous zeros at 4AM, ...
    (Linux-Kernel)
  • Re: 0 * X = null?
    ... Your friend is changing the terms of the description on you midway. ... If the context is counting ... X's then it must stay with counting X's and not jump to something else. ...
    (sci.math)