how many records

Lists: pgsql-novice
From: Bryan Irvine <bryan(dot)irvine(at)kingcountyjournal(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: how many records
Date: 2003-09-10 15:24:06
Message-ID: 1063207446.32209.1.camel@elvis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

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

--Bryan


From: Simon Willison <cs1spw(at)bath(dot)ac(dot)uk>
To: Bryan Irvine <bryan(dot)irvine(at)kingcountyjournal(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: how many records
Date: 2003-09-10 17:26:30
Message-ID: 3F5F5EC6.9060205@bath.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

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


From: "Louise Cofield" <lcofield(at)box-works(dot)com>
To: "'Bryan Irvine'" <bryan(dot)irvine(at)kingcountyjournal(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: how many records
Date: 2003-09-10 17:27:27
Message-ID: 000c01c377c0$ce742450$7801a8c0@Louise
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

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

-Louise

-----Original Message-----
From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org] On Behalf Of Bryan Irvine
Sent: Wednesday, September 10, 2003 9:24 AM
To: pgsql-novice(at)postgresql(dot)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(at)postgresql(dot)org


From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Bryan Irvine <bryan(dot)irvine(at)kingcountyjournal(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: how many records
Date: 2003-09-10 17:35:28
Message-ID: 1063215328.21803.127.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

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(dot)Elphick(at)lfix(dot)co(dot)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


From: "M(dot) Bastin" <marcbastin(at)mindspring(dot)com>
To: Bryan Irvine <bryan(dot)irvine(at)kingcountyjournal(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: how many records
Date: 2003-09-10 17:38:34
Message-ID: a0600200abb8511fc9f4b@[192.168.0.14]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

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(at)postgresql(dot)org


From: Stuart Woodward <woodward(at)garage(dot)co(dot)jp>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: how many records
Date: 2003-09-11 01:20:23
Message-ID: 20030911101954.F765.WOODWARD@garage.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

> 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(at)bath(dot)ac(dot)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.)


From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Stuart Woodward <woodward(at)garage(dot)co(dot)jp>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: how many records
Date: 2003-09-11 01:50:27
Message-ID: 20030911015027.GA8580@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Thu, Sep 11, 2003 at 10:20:23 +0900,
Stuart Woodward <woodward(at)garage(dot)co(dot)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(at)bath(dot)ac(dot)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.