Re: The standard 'why does it take so long' question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: The standard 'why does it take so long' question
Date: 2002-08-09 04:36:10
Message-ID: 28082.1028867770@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Nigel J. Andrews" <nandrews(at)investsystems(dot)co(dot)uk> writes:
> The first question is why would the index scan on chat_user take
> significantly longer than before?

I think the indexscan is having to skip over more irrelevant data in the
second case. Think about it: you can scan an index range consisting of
a single user's posts between times T1 and T2, or you can scan an index
range consisting of all posts between times T1 and T2. The second
column of the index will save you from actually going to the heap for
posts from other users, but you'll still have to pass over those index
entries, because the contiguous range of index entries that covers the
data you want will include a a lot of posts from other users.

What interests me is why the planner chose the second index when it
had a choice; I'd have thought its cost models were good enough to
handle this subtlety. Can you post the pg_stats rows for the columns
in question?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2002-08-09 04:43:51 Re: Question: merit / feasibility of compressing frontend
Previous Message Joe Conway 2002-08-09 04:19:50 Re: The standard 'why does it take so long' question