pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fernando Hevia <fhevia@ip-tel.com.ar>
To: 'Keresztury Balázs' <balazs@gaslightmusic.hu>
To: pgsql-performance@postgresql.org
Subject: Re: forced sequential scan when condition has current_user
Date: Tue, 5 Jan 2010 11:15:38 -0300
Message-ID: <2C6DE1FB86AB4DFD9B8D19853E7F5560@iptel.com.ar> (raw)
In-Reply-To: <000f01ca8d87$88e71f30$9ab55d90$@hu>
References: <000f01ca8d87$88e71f30$9ab55d90$@hu>

 

> -----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






view thread (9+ messages)  latest in thread

Message-ID: <2C6DE1FB86AB4DFD9B8D19853E7F5560@iptel.com.ar>
Permalink:  ../2C6DE1FB86AB4DFD9B8D19853E7F5560@iptel.com.ar/
Also on:    postgresql.org/message-id/2C6DE1FB86AB4DFD9B8D19853E7F5560@iptel.com.ar

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: fhevia@ip-tel.com.ar, balazs@gaslightmusic.hu
  Subject: Re: forced sequential scan when condition has current_user
  In-Reply-To: <2C6DE1FB86AB4DFD9B8D19853E7F5560@iptel.com.ar>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox