Re: Or selection on index versus union

From: han(dot)holl(at)informationslogik(dot)nl
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Or selection on index versus union
Date: 2005-10-05 09:13:58
Message-ID: 200510051113.58608.han.holl@informationslogik.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tuesday 04 October 2005 23:08, Michael Fuhr wrote:
> On Tue, Oct 04, 2005 at 09:32:41PM +0200, han(dot)holl(at)informationslogik(dot)nl wrote:
> > I've got a table with an index, let's call it fase.
> >
> > The following query is fine: 'select something from table where fase =
> > '1';
> >
> > However, this is disastrously slow:
> > select something from table where fase = '1' or fase = '2';
>
> Could we see some EXPLAIN ANALYZE output? What version of PostgreSQL
> are you using? Have you run VACUUM ANALYZE on the table to remove
> dead tuples and update the statistics? Have you considered clustering
> the table on fase's index?
>

Oh, well, thanks. I hadn't realized that a newly loaded database needs a vacuum analyze to begin with. And what's worse, I had the impression that vacuum full would include analyze, wich I see now it doesn't.

I'm not a database administrator, and I'm afraid it shows. I'm going to read a lot of docs in the coming months, because real people depend on reasonable performance of our databases.

Cheers, and thanks again,

Han Holl

PS We still have to be careful how to formulate conditions:
where fase in ('1','2')
is ok, and uses the index, but the logically identical:
where position(fase in '12') >= 1
does a sequential scan.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Markus Schulz 2005-10-05 09:38:19 Re: selfmade datatype in C and server-crash
Previous Message Martijn van Oosterhout 2005-10-05 08:45:04 Re: transaction toggling