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

Re: Why those queries do not utilize indexes?

From: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
To: Artimenko Igor <igorart7(at)yahoo(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Why those queries do not utilize indexes?
Date: 2004-08-27 19:49:12
Message-ID: Pine.LNX.4.44.0408272146260.9559-100000@zigo.dhs.org (view raw or flat)
Thread:
Lists: pgsql-performance
On Fri, 27 Aug 2004, Artimenko Igor wrote:

> 1. Sequential search and very high cost if set enable_seqscan to on;
> Seq scan on messageinfo ( cost=0.00..24371.30, rows =36802 )
> 
> 2. Index scan but even bigger cost if set enable_seqscan to off;
> Index “messagesStatus” on messageinfo ( Cost=0.00..27220.72, rows=36802 )

So pg thinks that a sequential scan will be a little bit faster (The cost 
is a little bit smaller). If you compare the actual runtimes maybe you 
will see that pg was right. In this case the cost is almost the same so 
the runtime is probably almost the same.

When you have more data pg will start to use the index since then it will 
be faster to use an index compared to a seq. scan.

-- 
/Dennis Björklund


In response to

Responses

pgsql-performance by date

Next:From: Mischa SandbergDate: 2004-08-27 19:50:12
Subject: Re: Equivalent praxis to CLUSTERED INDEX?
Previous:From: Bruce MomjianDate: 2004-08-27 19:42:50
Subject: Re: Equivalent praxis to CLUSTERED INDEX?

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