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

Home -> Community -> Usenet -> comp.databases.theory -> Re: counting rows

Re: counting rows

From: Tony Rogerson <tonyrogerson_at_sqlserverfaq.com>
Date: Fri, 31 Mar 2006 08:46:20 +0100
Message-ID: <e0imo5$312$1$8302bc10@news.demon.co.uk>


Number 2 will be best because you are effectively storing the aggregate instead of the server having to count the number of rows in the table which would require IO.

Tony.

-- 
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials


<bucaliman_at_gmail.com> wrote in message 
news:1143753100.408985.38260_at_u72g2000cwu.googlegroups.com...

> Consider the tables USERS and PICTURES. When retrieving the number of
> pictures from a user there are two ways:
>
> 1) I count them from pictures table.
> 2) I pick it directly from a field "numPictures" in table users.
>
> How are you used to do this? Which is better?
> Thanks
>
Received on Fri Mar 31 2006 - 01:46:20 CST

Original text of this message

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