Re: Creating Index

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: CN <cnliou9(at)fastmail(dot)fm>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Creating Index
Date: 2003-10-01 12:21:22
Message-ID: Pine.LNX.4.44.0310011419060.2932-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

CN writes:

> Table1 contains 9000 rows and table2 contains 0 row. This query, which
> takes 13489 msec, is extremely slow as pgsql sequentially scans all rows
> in table1:
>
> EXPLAIN ANALYZE SELECT COUNT(*) FROM view1;

Unqualified count() cannot use an index because it has to visit all the
rows in the table. Then again, I don't quite believe that visiting 9000
rows takes 13 seconds. Can you show us the result of EXPLAIN ANALYZE and
your real table and view definitions, because the ones you showed
contained a few syntax errors.

--
Peter Eisentraut peter_e(at)gmx(dot)net

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-10-01 14:26:34 Re: Determining Inheritance
Previous Message CN 2003-10-01 11:47:46 Creating Index