X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7C2E7D1B912 for ; Thu, 9 Oct 2003 15:34:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 54356-03 for ; Thu, 9 Oct 2003 12:33:34 -0300 (ADT) Received: from colsweeper.cranel.com (newmail.cranel.com [12.32.71.147]) by svr1.postgresql.org (Postfix) with ESMTP id 28EEBD1B936 for ; Thu, 9 Oct 2003 12:26:35 -0300 (ADT) Received: from colmail01.cranel.com (colmail01.cranel.com) by colsweeper.cranel.com (Content Technologies SMTPRS 4.2.5) with ESMTP id ; Thu, 9 Oct 2003 11:28:32 -0400 Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by colmail01.cranel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id T6NHF32J; Thu, 9 Oct 2003 11:29:17 -0400 Message-ID: <3F857E1C.1040209@cranel.com> Date: Thu, 09 Oct 2003 11:26:20 -0400 From: Greg Spiegelberg Organization: Cranel, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: PgSQL Performance ML Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310081010.26576.josh@agliodbs.com> <3F84613D.8040207@cranel.com> <200310081611.59179.josh@agliodbs.com> In-Reply-To: <200310081611.59179.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/276 X-Sequence-Number: 4024 Josh Berkus wrote: > 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. > Got it. I can see how it would be more efficient in storing. At this point it would require a lot of query and code rewrites to handle it. Fortunately, we're looking for alternatives for the next revision and we're leaving ourselves open for a rewrite much to the boss's chagrin. I will be spinning up a test server soon and may attempt a quick implementation. I may make value_type a foreign key on a table that includes a full and/or brief description of the key. Problem I'll have then will be categorizing all those keys into disk, cpu, memory, user, and all the other data categories since it's in one big table rather than specialized tables. Greg -- Greg Spiegelberg Sr. Product Development Engineer Cranel, Incorporated. Phone: 614.318.4314 Fax: 614.431.8388 Email: gspiegelberg@Cranel.com Cranel. Technology. Integrity. Focus.