Re: The REAL cost of joins - Mailing list pgsql-general

From Richard Huxton
Subject Re: The REAL cost of joins
Date
Msg-id 4B8F73B4.40600@archonet.com
Whole thread Raw
In response to The REAL cost of joins  (Marcin Krol <mrkafk@gmail.com>)
Responses Re: The REAL cost of joins  (Grzegorz Jaśkiewicz <gryzman@gmail.com>)
Re: The REAL cost of joins  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-general
On 03/03/10 21:59, Marcin Krol wrote:
> What do you think of this? And in general: when (if?) should one
> denormalize data?

As a last resort. No sooner.

The support costs of denormalising your database is such that if you can
reasonably just buy more hardware / add caching / etc, do so.

Oh, and I'm afraid your tests are probably meaningless.
1. The times are too small to be accurate.
2. You have the overhead of starting psql and connecting to the
database, starting a new backend etc.
3. You have the overhead of parsing the query
4. You're fetching all rows (which presumably aren't many) - not a
terribly useful scenario.

If you wanted to measure actual join costs, you'd need to repeat the
tests (say) 100-1000 times in a loop, optionally with prepared plans.
Varying WHERE clauses might be useful too, if that's how your real
application will work.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Need to Reload a Dump File - Need to Delete the PGDATA directory Again?
Next
From: Dave Page
Date:
Subject: Re: Scratching my head why results are different between machines.