Index only select count(*) - Mailing list pgsql-general

From Toni Helenius
Subject Index only select count(*)
Date
Msg-id E6A9CAA76548CB4EB02D2E3B174DD3B1EF9E189425@ink.sad.syncrontech.com
Whole thread Raw
Responses Re: Index only select count(*)  (Alban Hertroys <haramrae@gmail.com>)
List 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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: C-language stored function and float4 type
Next
From: Alban Hertroys
Date:
Subject: Re: Index only select count(*)