Обсуждение: reltuples value less than rows in the table.

Поиск
Список
Период
Сортировка

reltuples value less than rows in the table.

От
parul
Дата:
I have a index in a table. The value of the reltuples value in the pg_class
table for this index is less than the number of rows in the table where the
index is present.
For eg. if i have 800 rows in the table , the reltuples in the pg_class for
the index show the value as 769.
What are the scenarios under which this kind of behaviour occurs?
Also iam not able to execute the queries involving the indexed column in the
where clause.
Please suggest the probable cause for this.
Also if i do a reindex on the table, the reltuple values updates to the
current no. of rows ie. 800.

--
View this message in context:
http://postgresql.1045698.n5.nabble.com/reltuples-value-less-than-rows-in-the-table-tp4729917p4729917.html
Sent from the PostgreSQL - performance mailing list archive at Nabble.com.

Re: reltuples value less than rows in the table.

От
"Kevin Grittner"
Дата:
parul <i.parultyagi@gmail.com> wrote:

> I have a index in a table. The value of the reltuples value in the
> pg_class table for this index is less than the number of rows in
> the table where the index is present.
> For eg. if i have 800 rows in the table , the reltuples in the
> pg_class for the index show the value as 769.
> What are the scenarios under which this kind of behaviour occurs?

The fine manual explains it here:

http://www.postgresql.org/docs/9.0/interactive/catalog-pg-class.html

To quote:

| Number of rows in the table. This is only an estimate used by the
| planner. It is updated by VACUUM, ANALYZE, and a few DDL commands
| such as CREATE INDEX.

Other operations which affect the number of rows in the table won't
change this column, so it can be off by a bit until the next
autovacuum or explicit operation which sets a new estimate.

> Also iam not able to execute the queries involving the indexed
> column in the where clause.

Are you saying that you expect that a plan would have been chosen
which would have used the index, but it is choosing some other plan?
If so, your best bet is to present the actual query.

http://wiki.postgresql.org/wiki/SlowQueryQuestions

-Kevin