pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Frost <jeff@pgexperts.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #6092: specific casting required for gist indexing of bigint
Date: Tue, 5 Jul 2011 23:43:50 GMT
Message-ID: <201107052343.p65NhoKD055167@wwwmaster.postgresql.org> (raw)


The following bug has been logged online:

Bug reference:      6092
Logged by:          Jeff Frost
Email address:      jeff@pgexperts.com
PostgreSQL version: 9.0.4
Operating system:   CentOS 5.5
Description:        specific casting required for gist indexing of bigint
Details: 

Ran into a situation with a customer who is using the btree_gist contrib
module to allow combined index of some tsearch data and two other columns.
One of these other columns is a bigint field.  I noticed that the combined
index won't be used by the planner unless you specifically cast the bare
number to a bigint.  Here's a quick test case:

createdb jefftest
psql -f /usr/pgsql-9.0/share/contrib/btree_gist.sql jefftest

jefftest=# create table test (id bigint);
CREATE TABLE
Time: 28.541 ms
jefftest=# insert into test select generate_series(1,100000);
INSERT 0 100000
Time: 179.768 ms
jefftest=# CREATE INDEX test__id ON test using gist(id) ;
CREATE INDEX
Time: 1603.811 ms
jefftest=# ANALYZE test;
ANALYZE
Time: 21.854 ms
jefftest=# explain analyze select id from test WHERE id = 587;
                                             QUERY PLAN                     
                       
----------------------------------------------------------------------------
------------------------
 Seq Scan on test  (cost=0.00..1693.00 rows=500 width=8) (actual
time=0.097..14.698 rows=1 loops=1)
   Filter: (id = 587)
 Total runtime: 14.739 ms
(3 rows)

Time: 32.965 ms
jefftest=# explain analyze select id from test WHERE id = 587::bigint;
                                                     QUERY PLAN             
                                       
----------------------------------------------------------------------------
----------------------------------------
 Bitmap Heap Scan on test  (cost=20.16..490.49 rows=500 width=8) (actual
time=0.037..0.038 rows=1 loops=1)
   Recheck Cond: (id = 587::bigint)
   ->  Bitmap Index Scan on test__id  (cost=0.00..20.03 rows=500 width=0)
(actual time=0.027..0.027 rows=1 loops=1)
         Index Cond: (id = 587::bigint)
 Total runtime: 0.080 ms
(5 rows)

Time: 0.592 ms



view thread (4+ messages)  latest in thread

Message-ID: <201107052343.p65NhoKD055167@wwwmaster.postgresql.org>
Permalink:  ../201107052343.p65NhoKD055167@wwwmaster.postgresql.org/
Also on:    postgresql.org/message-id/201107052343.p65NhoKD055167@wwwmaster.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: jeff@pgexperts.com
  Subject: Re: BUG #6092: specific casting required for gist indexing of bigint
  In-Reply-To: <201107052343.p65NhoKD055167@wwwmaster.postgresql.org>
  References: <201107052343.p65NhoKD055167@wwwmaster.postgresql.org>

* 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