X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id F20DED1D729 for ; Wed, 19 Nov 2003 10:01:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 45224-01 for ; Wed, 19 Nov 2003 06:00:52 -0400 (AST) Received: from stan.aopsys.com (m173.net81-64-15.noos.fr [81.64.15.173]) by svr1.postgresql.org (Postfix) with ESMTP id A9B82D1D630 for ; Wed, 19 Nov 2003 06:00:43 -0400 (AST) Received: from localhost ([127.0.0.1] helo=news.nerim.net) by stan.aopsys.com with esmtp (Exim 3.36 #1 (Debian)) id 1AMP0t-0007ZF-00; Wed, 19 Nov 2003 10:52:43 +0100 To: Shridhar Daithankar Cc: pgsql-performance@postgresql.org Subject: Re: Join on incompatible types References: <87k75ym1v7.fsf@news.nerim.net> <3FB9F855.7010905@myrealbox.com> <87oev9lsgs.fsf@news.nerim.net> <3FBB138C.4090303@myrealbox.com> From: Laurent Martelli Organization: AOPSYS Date: Wed, 19 Nov 2003 10:52:43 +0100 In-Reply-To: <3FBB138C.4090303@myrealbox.com> (Shridhar Daithankar's message of "Wed, 19 Nov 2003 12:24:04 +0530") Message-ID: <87u150k7mc.fsf@news.nerim.net> User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/153 X-Sequence-Number: 4713 >>>>> "Shridhar" == Shridhar Daithankar writes: Shridhar> Laurent Martelli wrote: >>>>>>> "Shridhar" == Shridhar Daithankar >>>>>>> writes: Shridhar> Laurent Martelli wrote: >> [...] >> Should I understand that a join on incompatible types >> (such as >> integer and varchar) may lead to bad performances ? Shridhar> Conversely, you should enforce strict type compatibility Shridhar> in comparisons for getting any good plans..:-) >> Ha ha, now I understand why a query of mine was so sluggish. Is >> there a chance I could achieve the good perfs without having he >> same types ? I've tried a CAST in the query, but it's even a >> little worse than without it. However, using a view to cast >> integers into varchar gives acceptable results (see at the end). >> I'm using Postgresql 7.3.4. 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. The solution for me would rather be to have varchar everywhere. Shridhar> 2. Try following query EXPLAIN ANALYZE SELECT * from lists Shridhar> join classes on classes.id=lists.value where Shridhar> lists.id='16'::integer; Shridhar> How does it affect the runtime? Shridhar> Shridhar -- Laurent Martelli laurent@aopsys.com Java Aspect Components http://www.aopsys.com/ http://jac.aopsys.com