From: Josh Berkus <josh@agliodbs.com>
To: Greg Spiegelberg <gspiegelberg@cranel.com>
To: PgSQL Performance ML <pgsql-performance@postgresql.org>
Subject: Re: Compare rows
Date: Wed, 8 Oct 2003 16:11:59 -0700
Message-ID: <200310081611.59179.josh@agliodbs.com> (raw)
In-Reply-To: <3F84613D.8040207@cranel.com>
References: <3F841A28.8060504@cranel.com>
<200310081010.26576.josh@agliodbs.com>
<3F84613D.8040207@cranel.com>
Greg,
> You lost me on that one. What's a "vertical child table"?
Currently, you store data like this:
id address uptime speed memory tty
3 67.92 0.3 11.2 37 6
7 69.5 1.1 NULL 15 NULL
9 65.5 0.1 NULL 94 2
The most efficient way for you to store data would be like this:
main table
id address
3 67.92
7 69.5
9 65.5
child table
id value_type value
3 uptime 0.3
3 speed 11.2
3 memory 37
3 tty 6
7 uptime 1.1
7 memory 15
9 uptime 0.1
9 memory 94
9 tty 2
As you can see, the NULLs are not stored, making this system much more
efficient on storage space.
Tommorrow I'll (hopefully) write up how to query this for comparisons. It
would help if you gave a little more details about what specific comparison
you're doing, e.g. between tables or table to value, comparing just the last
value or all rows, etc.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: josh@agliodbs.com, gspiegelberg@cranel.com
Subject: Re: Compare rows
In-Reply-To: <200310081611.59179.josh@agliodbs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox