Re: Shall I apply normalization in the following case? - Mailing list pgsql-general

From Lew
Subject Re: Shall I apply normalization in the following case?
Date
Msg-id hkeo58$v71$1@news.albasani.net
Whole thread Raw
In response to Re: Shall I apply normalization in the following case?  (Sim Zacks <sim@compulab.co.il>)
List pgsql-general
Sim Zacks wrote:
> 2) querying on an int is quicker then querying on a string, so if you
> query on the values without the join you will have better performance.

The point of Jorge's approach is that it allows a query without a join.

With the OP's normalization, using integer keys, a join was required,
obviating any advantage to the integer key.

The assertion that a query involving integer keys is always faster than one
with string keys is unsafe at best.  The first rule of performance
optimization is that optimizations don't.

You have to test and measure to find out when and if they do.

Misuse of surrogate keys to obtain optimization is a prime example.  I've seen
situations in the field several times when such abuse forces extra joins in
queries and an increase in the number of indexes to maintain.  Without
measurement under representative workloads, especially concurrent activity,
it's impossible to know whether the cost outweighs the benefit.

--
Lew

pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Postgres wal shipping from 8.33 to 8.42.
Next
From: Scott Marlowe
Date:
Subject: Re: Postgres wal shipping from 8.33 to 8.42.