Index only select count(*)

From: Toni Helenius <Toni(dot)Helenius(at)syncrontech(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Index only select count(*)
Date: 2013-10-07 09:23:59
Message-ID: E6A9CAA76548CB4EB02D2E3B174DD3B1EF9E189425@ink.sad.syncrontech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I have a table with 961 columns. 1 of the columns is included in a primary key. The table has 52 760 rows. The table size is 137 MB and indexes size is 1176 kB (just the primary key). When I try:
SELECT count(*)
on it, it uses Seq Scan instead of Index scan. The query takes ~3 seconds. I have almost 500 similar tables. No index scans, why?

I'm using PostgreSQL 9.2.4 server. And I've read https://wiki.postgresql.org/wiki/Index-only_scans , apparently without understanding it. This is quite a performance issue to us. I've manually vacuumed and recreated indexes and all. No help. The output of analyze:
"Aggregate (cost=18240.50..18240.51 rows=1 width=0)"
" -> Seq Scan on min1_009 (cost=0.00..18108.60 rows=52760 width=0)"

--
Toni Helenius

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2013-10-07 09:31:21 Re: Index only select count(*)
Previous Message Tom Lane 2013-10-07 08:21:20 Re: C-language stored function and float4 type