Index optimization ?

From: Bo Lorentsen <bl(at)netgroup(dot)dk>
To: pgsql-general(at)postgresql(dot)org
Subject: Index optimization ?
Date: 2005-01-15 18:03:43
Message-ID: 41E95AFF.40505@netgroup.dk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi ...

In my quest to get rid of the oid dependency, i have made some new low
level code with the help from many nice people from this community
(thanks for that), but I still have one somewhat big problem.

I am running PG 7.4.6, btw.

I have a "sale" table that have a BIGSERIAL as primary key, but explain
keeps telling me (and so does the performance) that it will perform a
"seq scan" of my table when performing this statement (not using the
pkey index) :

select * from sale where id = currval( 'sale_id_seq' );

I tried this too :

select * from sale where id = currval( 'sale_id_seq' )::bigint;

But this still did not work (still using seq scan) :-(

At last I did a :

explain select * from sale where id = 42::bigint;

Just to make sure, and this made the proper optimizations (used the pkey
index).

What have I done wrong, or do PG still have some casting problems in the
optimizer ?

/BL

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bo Lorentsen 2005-01-15 18:10:48 Re: OID Usage
Previous Message Tom Lane 2005-01-15 17:45:27 Re: PQisBusy() always returns TRUE