From: Guillaume Cottenceau <gc@mnc.ch>
To: Kai Sellgren <kaisellgren@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Slow counting on v9.3
Date: Thu, 16 Jan 2014 09:42:57 +0100
Message-ID: <m3sisojp0u.fsf@mnc.ch> (raw)
In-Reply-To: <CANyR-3ecSwJN9eOLtOLictrnAp0JomF+ZKO-xBVQRtFhzn5gWw@mail.gmail.com>
References: <CANyR-3ecSwJN9eOLtOLictrnAp0JomF+ZKO-xBVQRtFhzn5gWw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
Kai Sellgren <kaisellgren 'at' gmail.com> writes:
> Hi,
>
> I'm experiecing slow count performance:
>
> SELECT COUNT(*) AS "count"
> FROM "NewsArticle"
>
> Takes 210 ms. I've run analyze and vacuum. I'm on 9.3. Here're the stats http:/
> /d.pr/i/6YoB
>
> I don't understand why is it that slow. It returns 1 integer, and counts
> without filters.
You might actually have a lot more dead tuples than reported in
statistic. Last vacuum is old according to your screenshot. Try
"VACUUM FULL ANALYZE" on your table, then try again counting.
> This performs quickly:
>
> SELECT reltuples AS count
> FROM pg_class
> WHERE relname = 'NewsArticle';
This is not the same. This one uses precomputed statistics, and
doesn't scan the actual table data.
> But I'd like to add conditions so I don't like the last method.
>
>
> --
> Yours sincerely,
> Kai Sellgren
--
Guillaume Cottenceau
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: gc@mnc.ch, kaisellgren@gmail.com
Subject: Re: Slow counting on v9.3
In-Reply-To: <m3sisojp0u.fsf@mnc.ch>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox