Re: optimizing Postgres queries - Mailing list pgsql-performance

From Shridhar Daithankar
Subject Re: optimizing Postgres queries
Date
Msg-id 200401051740.05006.shridhar_daithankar@myrealbox.com
Whole thread Raw
In response to Re: optimizing Postgres queries  (David Teran <david.teran@cluster9.com>)
Responses Re: optimizing Postgres queries
List pgsql-performance
On Monday 05 January 2004 17:35, David Teran wrote:
> explain analyze SELECT --columns-- FROM KEY_VALUE_META_DATA t0 WHERE
> t0.ID_FOREIGN_TABLE = 21110;
>
> i see that no index is being used whereas when i use
>
> explain analyze SELECT --columns-- FROM KEY_VALUE_META_DATA t0 WHERE
> t0.ID_FOREIGN_TABLE = 21110::bigint;
>
> an index is used. Very fine, the performance is about 10 to 100 times
> faster for the single select.
>
> I am using WebObjects with JDBC. I will now create a DB with integer
> instead of bigint and see how this performs.

The performance will likely to be the same. Its just that integer happens to
be default integer type and hence it does not need an explicit typecast. ( I
don't remember exactly which integer is default but it is either of int2,int4
and int8...:-))

The performance diffference is likely due to use of index, which is in turn
due to typecasting. If you need bigint, you should use them. Just remember to
typecast whenever required.

 Shridhar


pgsql-performance by date:

Previous
From: David Teran
Date:
Subject: Re: optimizing Postgres queries
Next
From: David Teran
Date:
Subject: Re: optimizing Postgres queries