Re: Table count option

From: Dave Page <dpage(at)postgresql(dot)org>
To: Melvin Davidson <mdavidson(at)cctus(dot)com>, "'pgadmin-support(at)postgresql(dot)org'" <pgadmin-support(at)postgresql(dot)org>
Subject: Re: Table count option
Date: 2006-11-15 21:56:01
Message-ID: 455B8CF1.2030400@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

Melvin Davidson wrote:
> OK, one more time.
>
> Yes I know that right click count does that!
>
> I know about select count(*).
> I know about Right-click -> Count
>
> The question was/is "What is the equivalent SQL function to update the
> Rows(counted) value?

Right, one more time :-)

There is no SQL function. It just does a SELECT count(*) and updates the
value stored in memory (in the pgTable object to be precise).

> IOW, What is the underlying code in Right-click -> Count?

Ultimately, once you get clear of all the menu handling code you get to:

void pgTable::UpdateRows()
{
pgSet *props = ExecuteSet(wxT("SELECT count(*) AS rows FROM ONLY ")
+ GetQuotedFullIdentifier());
if (props)
{
rows = props->GetLongLong(0);
delete props;
rowsCounted = true;
}
}

pgTable.rows contains the row count.
pgTable.rowsCounted is a flag that indicates that a count has been done,
rather than an estimate made (estimates come from pg_class.reltuples,
which is populated by ANALYZE).

Regards, Dave

Browse pgadmin-support by date

  From Date Subject
Next Message Jim Cullison 2006-11-15 22:06:32 Little bug changing db owner
Previous Message Dave Page 2006-11-15 21:43:56 Re: Table count option