pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shridhar Daithankar <shridhar@frodo.hserus.net>
To: pgsql-performance@postgresql.org
Subject: Re: Queries with timestamp II
Date: Mon, 26 Jan 2004 20:08:13 +0530
Message-ID: <40152655.6080605@frodo.hserus.net> (raw)
In-Reply-To: <049101c3e416$74023120$3c0aa8c0@iberica.andromeiberica.com>
References: <049101c3e416$74023120$3c0aa8c0@iberica.andromeiberica.com>

Arnau wrote:

> explain analyze select * from statistics2 where timestamp_in <
> to_timestamp( '20031201', 'YYYYMMDD' );
> NOTICE:  QUERY PLAN:
> 
> Seq Scan on statistics2  (cost=0.00..638.00 rows=9289 width=35) (actual
> time=0.41..688.34 rows=27867 loops=1)
> Total runtime: 730.82 msec
> 
> That query is not using the index. Anybody knows what I'm doing wrong?

Since it expects large number of rows will be returned, it is favouring 
sequential scan.

Given how the estimates have differed, i.e. estimated 9289 v/s actual 27867, I 
sugest you up the statistics for the table using alter table. Check
http://www.postgresql.org/docs/current/static/sql-altertable.html


HTH

  Shridhar



view thread (3+ messages)  latest in thread

Message-ID: <40152655.6080605@frodo.hserus.net>
Permalink:  ../40152655.6080605@frodo.hserus.net/
Also on:    postgresql.org/message-id/40152655.6080605@frodo.hserus.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: shridhar@frodo.hserus.net
  Subject: Re: Queries with timestamp II
  In-Reply-To: <40152655.6080605@frodo.hserus.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox