Re: optimizing Postgres queries

From: Shridhar Daithankar <shridhar_daithankar(at)myrealbox(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: optimizing Postgres queries
Date: 2004-01-05 12:10:05
Message-ID: 200401051740.05006.shridhar_daithankar@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message David Teran 2004-01-05 12:18:06 Re: optimizing Postgres queries
Previous Message David Teran 2004-01-05 12:05:03 Re: optimizing Postgres queries