RE: Using BOOL in indexes - Mailing list pgsql-hackers

From Hiroshi Inoue
Subject RE: Using BOOL in indexes
Date
Msg-id 000401bfcab7$b36aa580$2801007e@tpf.co.jp
Whole thread Raw
In response to Re: Using BOOL in indexes  (Andrew McMillan <Andrew@catalyst.net.nz>)
List pgsql-hackers
> -----Original Message-----
> From: andrew@socrates.catalyst.net.nz
> 
> Hiroshi Inoue wrote:
> > Hiroshi Inoue wrote:
> > > Andrew McMillan wrote:
> > > >
> > > > Hi,
> > > >
> > 
> > Sorry,it wouldn't help unless there's an index e.g. on (head1,written,
> > story_id, released, title, precis, author).
> > However isn't (story_id) a primary key ?
> > If so,couldn't you change your query as follows ?
> > 
> > SELECT story.story_id, written, released, title, precis, author, head1
> > FROM story WHERE head1=TRUE ORDER BY head1, written DESC
> > LIMIT 15.
> 
> Thanks Hiroshi,
> 
> I already have such an index, but as you can see below, it is still not
> used:
> 
> newsroom=# explain SELECT story.story_id, written, released, title,
> precis, author, head1 FROM story WHERE head1=TRUE ORDER BY head1,
> written DESC LIMIT 15;

Oops,please add DESC to head1 also i.e ORDER BY head1 DESC,written DESC.

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp


pgsql-hackers by date:

Previous
From: Andrew McMillan
Date:
Subject: Re: Using BOOL in indexes
Next
From: Grant Finnemore
Date:
Subject: Re: SET FSYNC command?