Re: Join on incompatible types

From: Shridhar Daithankar <shridhar_daithankar(at)myrealbox(dot)com>
To: Laurent Martelli <laurent(at)aopsys(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Join on incompatible types
Date: 2003-11-19 10:19:23
Message-ID: 3FBB43AB.30302@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Laurent Martelli wrote:

>>>>>>"Shridhar" == Shridhar Daithankar <shridhar_daithankar(at)myrealbox(dot)com> writes:
> Shridhar> I am stripping the analyze outputs and directly jumping to
> Shridhar> the end.
>
> Shridhar> Can you try following?
>
> Shridhar> 1. Make all fields integer in all the table.
>
> I can't do this because lists.values contains non integer data which
> do not refer to a classes.id value. It may sound weird. This is
> because it's a generic schema for a transparent persistence framework.

Fine .I understand. So instead of using a field value, can you use integer
version of that field? (Was that one of your queries used that? I deleted the OP)

> The solution for me would rather be to have varchar everywhere.

You need to cast every occurance of that varchar field appropriately, to start
with. The performance might suffer as well for numbers.

> Shridhar> 2. Try following query EXPLAIN ANALYZE SELECT * from lists
> Shridhar> join classes on classes.id=lists.value where
> Shridhar> lists.id='16'::integer;

classes.id=lists.value::integer.

Try that.

The aim is absolute type compatibility. If types aren't exactly same, the plan
is effectively dead.

<OT>
I would say postgresql enforces good habits in it's application developers, from
a cultural POV.

Had C refused to compile without such strict type compatibility, we wouldn't
have to worry about 16bit/32bit and 64 bit software. Just upgrade the compiler
and everything is damn good..:-)

I doubt if C would have so popular with such strict type checking but that is
another issue. I think pascal enforces such strict syntax.. Not sure though..
</OT>

Shridhar

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Laurent Martelli 2003-11-19 12:16:03 Re: Join on incompatible types
Previous Message Laurent Martelli 2003-11-19 09:52:43 Re: Join on incompatible types