From: Steve Wampler <swampler@noao.edu>
To: postgres-sql <pgsql-sql@postgresql.org>
Subject: Tagging rows into collections?
Date: Wed, 19 Jun 2002 09:02:03 -0700
Message-ID: <3D10AAFB.D51B1B66@noao.edu> (raw)
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.
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-sql@postgresql.org
Cc: swampler@noao.edu
Subject: Re: Tagging rows into collections?
In-Reply-To: <3D10AAFB.D51B1B66@noao.edu>
* 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