Re: Arrays vs separate tables - Mailing list pgsql-general

From Ray O'Donnell
Subject Re: Arrays vs separate tables
Date
Msg-id 01020199fe3f6030-5d953b42-e08d-4782-9da3-3d635f5445af-000000@eu-west-1.amazonses.com
Whole thread Raw
In response to Arrays vs separate tables  (Rich Shepard <rshepard@appl-ecosys.com>)
Responses Re: Arrays vs separate tables
List pgsql-general
On 19/10/2025 21:43, Rich Shepard wrote:

> In the former book I read that sometimes it's better to have multiple 
> values
> for an atribute in a single row by creating a separate table for that
> attribute rather than using the postgres array capability. The people 
> table
> in my database (1706 rows) has two attributes using the array type
> (direct_phone and email), and only a few indivuals have multiple landline
> phone numbers (cell_phone is a separate column) or email addresses 
> (office
> and personal?). Would it make sense for me to create new landline and 
> email
> address tables and replace the array contents?
>
My experience of doing something similar was that arrays work very well 
for the use-case you describe, as long as you don't have to search 
inside the arrays... I found that, if you have to search for a specific 
value inside an array, then performance really goes out the window. Mind 
you, clever use of an index would probably help here.

Ray.

-- 
Ray O'Donnell // Galway // Ireland
ray@rodonnell.ie




pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Arrays vs separate tables
Next
From: Rich Shepard
Date:
Subject: Re: Arrays vs separate tables