Re: Index problem

From: "Matt Clark" <matt(at)ymogen(dot)net>
To: <rigmor(dot)ukuhe(at)finestmedia(dot)com>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Index problem
Date: 2003-09-25 12:13:32
Message-ID: OAEAKHEHCMLBLIDGAFELKEBIDMAA.matt@ymogen.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> There are about 2500 rows in that table.
>
> 1st query explain analyze: Seq Scan on PRIORITY_STATISTICS
> (cost=0.00..491.44 rows=127 width=12) (actual time=98.58..98.58 rows=0
> loops=1)
> Total runtime: 98.74 msec
>
> 2nd query explain analyze: NOTICE: QUERY PLAN:
>
> Index Scan using PRIORITY_STATISTICS_reo_id, PRIORITY_STATISTICS_reo_id,
[snip]
> PRIORITY_STATISTICS_reo_id on PRIORITY_STATISTICS (cost=0.00..394.06
> rows=102 width=12) (actual time=20.93..20.93 rows=0 loops=1)
> Total runtime: 21.59 msec

With only 2500 rows the planner could be deciding that it's going to have to read every disk block to do an index scan anyway, so it
might as well do a sequential scan. If the pages are in fact in the kernel cache then the compute time will dominate, not the IO
time, so it ends up looking like a bad plan, but it's probably not really such a bad plan...

Is your effective_cache_size set to something sensibly large?

You could also try decreasing cpu_index_tuple_cost and cpu_tuple_cost. These will affect all your queries though, so what you gain
on one might be lost on another.

Matt

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Palle Girgensohn 2003-09-25 12:36:53 performance hit when joining with a view?
Previous Message Rigmor Ukuhe 2003-09-25 10:22:40 Re: Index problem