Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id B7EDC47750B for ; Wed, 19 Jun 2002 13:07:42 -0400 (EDT) Received: from noao.edu (dns.noao.edu [140.252.1.54]) by postgresql.org (Postfix) with ESMTP id C81CF476F8F for ; Wed, 19 Jun 2002 12:01:58 -0400 (EDT) Received: from weaver.tuc.noao.edu ([140.252.38.8] verified) by noao.edu (CommuniGate Pro SMTP 3.5.6) with ESMTP id 4514794; Wed, 19 Jun 2002 09:02:03 -0700 Received: from noao.edu (localhost [127.0.0.1]) by weaver.tuc.noao.edu (8.11.6/8.11.6) with ESMTP id g5JG23f10204; Wed, 19 Jun 2002 09:02:03 -0700 Message-ID: <3D10AAFB.D51B1B66@noao.edu> Date: Wed, 19 Jun 2002 09:02:03 -0700 From: Steve Wampler Organization: National Solar Observatory X-Mailer: Mozilla 4.79 [en] (X11; U; Linux 2.4.9-31smp i686) X-Accept-Language: en MIME-Version: 1.0 To: postgres-sql Subject: Tagging rows into collections? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200206/251 X-Sequence-Number: 8216 I've got what I think is a fairly simple SQL question. Frist, some background. I'm building a database to log events produced by some scientific instruments. The postgresql database is attached to by muliple java programs using JDBC. An event has: timestamp,event_name,list_of_attributes The list_of_attributes are simple (string) name,value pairs. An event may have 1 or more attributes in its list (no upper limit is imposed by the system). Insertion performance is critical - selection performance *much* less so. I wrote a simple test version using a single table with columns: lab.devel.eventdb=# \d events_table Table "events_table" Attribute | Type | Modifier -----------+--------------------------+--------------- time | timestamp with time zone | default now() event | character varying(64) | not null name | character varying(64) | not null svalue | character varying(80) | The Java code accepts (via CORBA) events and then splits the events into multiple rows in this table (one row per attribute in the list_of_attributes). This works fine for insertion - it's simple and fast enough with transactions. However, although selection performance isn't a priority, the ability to reconstruct the events from the database is needed and the above simple table doesn't provide enough information to do so. (The resolution on the timestamp field isn't enough to distinquish separate events that have the same name.) Is there an obvious way to solve this (preserving insert performance as much as possible) at the database level? Or should I bite the bullet and solve it at the java level? I'm partial to a solution solving it at the database level because the fact that there are multiple event sources (java apps distributed across a network). I'm leaning toward two tables - one with rows of "timestamp,event" and an internal tag that can be used to identify rows of "name,svalue" in a second table, but I'm new enough to SQL to be uncertain of the best way to set this up and still get good insert performance. (And whether this would really be better than some approach using a single table.) Thanks for any guidance! Steve -- Steve Wampler -- swampler@noao.edu The gods that smiled on your birth are now laughing out loud.