Thread: how many records

how many records

From
Bryan Irvine
Date:
Is there an easy way to count how many records there are?

--Bryan


Re: how many records

From
"Louise Cofield"
Date:
The only way I have found to do this is with COUNT:
select count(*) from <tablename>;

-Louise

-----Original Message-----
From: pgsql-novice-owner@postgresql.org
[mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Bryan Irvine
Sent: Wednesday, September 10, 2003 9:24 AM
To: pgsql-novice@postgresql.org
Subject: [NOVICE] how many records

Is there an easy way to count how many records there are?

--Bryan


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


Re: how many records

From
Simon Willison
Date:
Bryan Irvine wrote:

> Is there an easy way to count how many records there are?

Yes, using count(*):

select count(*) from tablename;

Hope that helps,

Simon


Re: how many records

From
Oliver Elphick
Date:
On Wed, 2003-09-10 at 16:24, Bryan Irvine wrote:
> Is there an easy way to count how many records there are?

SELECT COUNT(*) FROM mytable;

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Draw near to God and he will draw near to you.
      Cleanse your hands, you sinners; and purify your
      hearts, you double minded."       James 4:8


Re: how many records

From
"M. Bastin"
Date:
SELECT COUNT(*) FROM mytable;

Marc

>Is there an easy way to count how many records there are?
>
>--Bryan
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


Re: how many records

From
Stuart Woodward
Date:
> Bryan Irvine wrote:
> Is there an easy way to count how many records there are?

On Wed, 10 Sep 2003 18:26:30 +0100
Simon Willison <cs1spw@bath.ac.uk> wrote:

> Yes, using count(*):
> select count(*) from tablename;

Is there any performance difference in explicitly naming a column to
count?

i.e select count(id) from tablename;

(I know that a lot of beginners always "select *" even when they don't
need all the information which (I think) is slower than selecting just
what need.)


Re: how many records

From
Bruno Wolff III
Date:
On Thu, Sep 11, 2003 at 10:20:23 +0900,
  Stuart Woodward <woodward@garage.co.jp> wrote:
> > Bryan Irvine wrote:
> > Is there an easy way to count how many records there are?
>
> On Wed, 10 Sep 2003 18:26:30 +0100
> Simon Willison <cs1spw@bath.ac.uk> wrote:
>
> > Yes, using count(*):
> > select count(*) from tablename;
>
> Is there any performance difference in explicitly naming a column to
> count?
>
> i.e select count(id) from tablename;

Note that select count(id) and select count(*) can return different numbers.
Select count(*) is equivalent to select count(1) and I believe that
transformation (or something equivalent) is made by postgres.