Re: Searing array fields - or should I redesign? - Mailing list pgsql-general

From Jan Kesten
Subject Re: Searing array fields - or should I redesign?
Date
Msg-id 995BA02F-7F35-4E41-A7A8-2D06DDF3E722@dafuer.de
Whole thread Raw
In response to Searing array fields - or should I redesign?  (Bryan Montgomery <monty@english.net>)
Responses Re: Searing array fields - or should I redesign?  (Vincent Veyron <vv.lists@wanadoo.fr>)
List pgsql-general
> eg, insert into logtable values ( 'vehicle123', now(), {{'voltage','13'},{'rpm','600'}};
>
> However, I am not sure how I can write a query - for example to read all records where the voltage field is less than
13.Performance in this case is not a real significant issue. 
>
> Would I be better off redesigning and having a master / detail kind of structure? Where the master table would have
thevehicle id, timestamp and a key to the detail table.  

The second approach would work quite well.

table logentry
  id primary unique
  vehicleid int
  logtime timestamp

table logdetail
  logid int
  attribute varchar/int
  value decimal
  textvalue varchar

You can retrieve logentries for specific vehicles, timeframes and attributes - and you can extend more log attributes
withoutchanging the database structure. I would suggest another table for the attributes where you can lookup if it is
atext or numeric entry. 

Just my two cents - and performance always matters (later in progress) ;-)

pgsql-general by date:

Previous
From: Bryan Montgomery
Date:
Subject: Searing array fields - or should I redesign?
Next
From: Adrian Klaver
Date:
Subject: Re: How to restore from backup to 8.4.3 server using 9.0 dump/restore