From: | Keresztury Balázs <balazs(at)gaslightmusic(dot)hu> |
---|---|
To: | "'Fernando Hevia'" <fhevia(at)ip-tel(dot)com(dot)ar> |
Cc: | <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: forced sequential scan when condition has current_user |
Date: | 2010-01-05 17:38:23 |
Message-ID: | 000901ca8e2d$e320f1a0$a962d4e0$@hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
You are right along with the others, the seq scan was only forced because of
the varchar-text comparision.. Using the cast solves the problem.
Thanks for the answers everyone!
Balazs
-----Original Message-----
From: Fernando Hevia [mailto:fhevia(at)ip-tel(dot)com(dot)ar]
Sent: Tuesday, January 05, 2010 3:16 PM
To: 'Keresztury Balázs'; pgsql-performance(at)postgresql(dot)org
Subject: RE: [PERFORM] forced sequential scan when condition has
current_user
> -----Mensaje original-----
> De: Keresztury Balázs
>
> hi,
>
> just a small question: is it normal that PostgreSQL 8.4.1
> always uses sequential scanning on any table when there is a
> condition having the constant "current_user"? Of course there
> is a btree index set on that table, but the DBMS just doesn't
> want to utilize it. When I replace current_user to any
> string, the planner uses the index normally.
>
> I can demonstrate it with the following simple query:
>
> SELECT psz.kotesszam FROM projekt.projektszervezet psz WHERE
> psz.felhasznalo_id = current_user;
>
Probably you are comparing different types. Try explicitly casting
current_user to text:
SELECT psz.kotesszam FROM projekt.projektszervezet psz WHERE
psz.felhasznalo_id = current_user::text
From | Date | Subject | |
---|---|---|---|
Next Message | Brian Cox | 2010-01-05 21:05:58 | Re: query looping? |
Previous Message | Robert Haas | 2010-01-05 15:03:37 | Re: query looping? |