From: | Ed Loehr <eloehr(at)austin(dot)rr(dot)com> |
---|---|
To: | John Henderson <jrh(at)is(dot)com(dot)fj> |
Cc: | pgsql-general(at)hub(dot)org |
Subject: | Re: [GENERAL] typecast for index |
Date: | 2000-02-14 05:33:18 |
Message-ID: | 38A7939E.2CB0762E@austin.rr.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
John Henderson wrote:
>
> This is what I want to do:
> select user_name, date_trunc('minutes',sum(is_roundup_01(sess_time)))
> from sessions_feb2000_homer s where
> date_part('epoch',start)>'949316399' and
> date_part('epoch',start)<'951822000' and
> prob here> user_name IN (select username from userdir
> where towncode = 'LAB')
> group by user_name
> order by user_name;
>
> The problem is that user_name = 'soandso' will use an index scan
> but user_name IN (select ...) uses a sequential scan.
>
> Any advice on how to force this to use an index?
> Yes the index exists, yes it has been vaccuumed. This is PG 6.5.3
IIRC, this is a known issue with 'IN', and that the traditional
solution was to replace use of 'IN' with 'EXISTS', i.e.,
and EXISTS (select * from userdir where user_name = username and
towncode...)
Cheers,
Ed Loehr
From | Date | Subject | |
---|---|---|---|
Next Message | John Henderson | 2000-02-14 05:59:23 | typecast for index |
Previous Message | Manuel Cabido | 2000-02-14 01:28:48 | Re: pgsql-general-digest V1 #638 |