Skip site navigation (1) Skip section navigation (2)

Re: Cross-datatype Comparisons and Indexes

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: "Thomas F(dot)O'Connell" <tfo(at)sitening(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Cross-datatype Comparisons and Indexes
Date: 2004-08-20 22:13:08
Message-ID: 41267774.8080809@mascari.com (view raw or flat)
Thread:
Lists: pgsql-general
Thomas F.O'Connell wrote:

> Since the current stable version of postgres (7.4.x) doesn't
> allow cross-datatype comparisons of indexes, is it always
> necessary to cast my application data explicitly in order for an
> index to be used, even among the integer types?
> 
> E.g., If I have a table with a bigint primary key and application
> data compared against that primary key, must I always explicitly
> cast the application data to bigint if I want postgres to use the
> index?
> 
> SELECT * FROM some_table WHERE primary_key_column = 42
> 
> vs.
> 
> SELECT * FROM some_table WHERE primary_key_column = 42::int8
> 
> There's no way to tell postgres to treat incoming data implicitly
> as the type of the column, right?

You can always set your initial sequence values to > 4.2 billion 
(2^32) which could also probably expose some 4-byte integer 
assumptions your code may make. You'd not need to use an explicit 
cast in that scenario either.

Mike Mascari


In response to

pgsql-general by date

Next:From: Marc G. FournierDate: 2004-08-21 00:19:38
Subject: New Stable Releases to Address Critical Bugs
Previous:From: Joshua D. DrakeDate: 2004-08-20 21:27:59
Subject: Re: Cross-datatype Comparisons and Indexes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group