Re: String versus integer joins?

From: Mark Wong <markwkm(at)gmail(dot)com>
To: Veronika Megler <vmegler(at)cecs(dot)pdx(dot)edu>
Cc: pdxpug(at)postgresql(dot)org
Subject: Re: String versus integer joins?
Date: 2012-10-23 19:12:34
Message-ID: CAE+TzGq7Ey5eoP9waFZzH1n0w7WwQs+W1fmYX=x-WNgRzkm9Xw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pdxpug

On Tue, Oct 23, 2012 at 9:40 AM, Veronika Megler <vmegler(at)cecs(dot)pdx(dot)edu> wrote:
> Hello all,
>
> I've heard persistent rumors that joining two table based on an integer id
> "must be" or "is" faster than joining on a string id.
>
> While I'd believe the "must be", does anyone have any pointers to (or
> evidence of) how much faster?
>
> I.e.; if the difference is 10 times, then it's worth us
> rewriting/testing/upgrading an application. If it's 10%, then it's not.

I have wondered how toasting affects things for the columns used in a
join if they were strings, specifically if there are actually 2x reads
done because of toasting varchars. But I believe as of 9.0 there was
work done so that varchars are not always toasted if the length is
restricted such that the table row fits in a page. It's been a long
time for me though, I might be spewing out nonsense that makes this
more confusing. If what I said is valid, I would assume the
performance would degrade significantly only if the dataset was large.

Regards,
Mark

In response to

Responses

Browse pdxpug by date

  From Date Subject
Next Message Darrell Fuhriman 2012-10-23 19:56:57 Re: String versus integer joins?
Previous Message Joshua D. Drake 2012-10-23 17:39:43 Re: String versus integer joins?