Skip site navigation (1) Skip section navigation (2)

Statistics issue

From: Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)ru>
To: pgsql-performance(at)postgresql(dot)org
Subject: Statistics issue
Date: 2008-05-30 11:02:41
Message-ID: 483FDED1.1070503@dc.baikal.ru (view raw or flat)
Thread:
Lists: pgsql-performance
I have a big table that is used in many queries. Most used index is
created on date field. Number of records in this table when date field
is saturday is about 5 times smaller than other days, on sunday this
number is always 0. Statistics target is 1000. Many queries have
problems when condition on this table looks like "d between '2007-05-12'
and '2007-05-12'" (saturday).

EXPLAIN ANALYZE
SELECT *
FROM i
WHERE d BETWEEN '2007-05-12' AND '2007-05-12'

Index Scan using i_d on i  (cost=0.00..2.39 rows=1 width=402) (actual
time=0.053..4.284 rows=1721 loops=1)
  Index Cond: ((d >= '2007-05-12'::date) AND (d <= '2007-05-12'::date))
Total runtime: 6.645 ms

EXPLAIN ANALYZE
SELECT *
FROM i
WHERE d = '2007-05-12'

Index Scan using i_d on i  (cost=0.00..38.97 rows=1572 width=402)
(actual time=0.044..4.250 rows=1721 loops=1)
  Index Cond: (d = '2007-05-12'::date)
Total runtime: 6.619 ms

Is there a way to solve this problem?


Responses

pgsql-performance by date

Next:From: Simon RiggsDate: 2008-05-31 07:44:57
Subject: Re: 2GB or not 2GB
Previous:From: Gregory StarkDate: 2008-05-30 00:19:11
Subject: Re: ProcArrayLock (The Saga continues)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group