Re: [SQL] arrays

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Mike Sosteric <mikes(at)athabascau(dot)ca>, Bruno Wolff III <bruno(at)wolff(dot)to>, <pgsql-general(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: [SQL] arrays
Date: 2002-10-01 17:52:53
Message-ID: web-1736209@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-sql

Achilleus,

> I was wondering why is such a rage against arrays.
>
> I posted 2 very common problems where arrays provide
> the only natural (and efficient) fit. (and got no responses)
> So it seems to me that:

All of your points are correct.

Us "old database hands" have a knee-jerk reaction against arrays for
long-term data storage because, much of the time, developers use arrays
because they are lazy or don't understand the relational model instead
of because they are the best thing to use. This is particularly true
of people who come to database development from, say, web design.

In this thread particularly, Mike was suggesting using arrays for a
field used in JOINs, which would be a royal mess. Which was why you
heard so many arguments against using arrays.

Or, to put it another way:

1. Array data types are perfect for storing data that arrives in the
form of arrays or matricies, such as scientific data , or interface
programs that store arrays of object properties.

2. For other purposes, arrays are a very poor substitute for proper
sub-table storage of related data according to the relational model.

3. The distinguishing factor is "atomicity": ask yourself: "is this
array a discrete and undivisible unit, or is is a collection of related
but mutable elements?" If the former, use and array. If the latter,
use a sub-table.

Clearer now?

-Josh Berkus

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2002-10-01 17:55:19 Re: cluster replication with intermezzo
Previous Message Johnson, Shaunn 2002-10-01 17:48:38 execute transaction / insert rows

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2002-10-01 20:03:40 Re: [COMMITTERS] pgsql/contrib/rserv ApplySnapshot.in CleanLog.
Previous Message Roland Roberts 2002-10-01 17:43:02 Re: [GENERAL] arrays

Browse pgsql-sql by date

  From Date Subject
Next Message bcschnei 2002-10-01 18:16:57 Stored Procedures
Previous Message Roland Roberts 2002-10-01 17:43:02 Re: [GENERAL] arrays