Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 14479475CB6 for ; Sat, 18 May 2002 11:51:52 -0400 (EDT) Received: from mx05.gis.net (mx05.gis.net [208.218.130.13]) by postgresql.org (Postfix) with ESMTP id AECEE475BE4 for ; Sat, 18 May 2002 11:51:50 -0400 (EDT) Received: from shell.gis.net ([208.218.129.18]) by mx05.gis.net; Sat, 18 May 2002 11:51:52 -0400 Date: Sat, 18 May 2002 11:47:38 -0400 (EDT) From: Chadwick Rolfs To: =?iso-8859-1?Q?Ga=EBtan_de_Menten?= Cc: pgsql-php@postgresql.org Subject: Re: Simple PHP/pgsql optimization question... In-Reply-To: <001601c1fe7e$bf271af0$0701a8c0@trotinette> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Transfer-Encoding: QUOTED-PRINTABLE X-Archive-Number: 200205/61 X-Sequence-Number: 1193 On Sat, 18 May 2002, [iso-8859-1] Ga=EBtan de Menten wrote: > Hi there all, >=20 > First, I'm far from being a professional programmer in pgsql and PHP and = I'm > new to this list, so please pardon if this question seems stupid to you. >=20 > In my 'projects' tables, among many other fields, I need a 'license' fiel= d. > I need to optimize the display of the list of all projects (+-200 projects > to display). > Which solution do you think would be the fastest, and how much faster? >=20 > 1) Have a 'license' table (with and id and a name field) listing all the > possible licenses and have a foreign key in my 'projects' table pointing = to > that 'license' table. > the query would look like this: > select ..., license.name as license from projects, licenses where > projects.license=3Dlicense.id and ... >=20 > 2) Have the license field in the 'projects' table be a varchar field and > store the name of the license directly. >=20 > 3) Have the license field be an int and have an array in PHP listing all = the > licenses. >=20 > 4) another solution? >=20 > I personnaly prefer the first solution since it's the cleanest to my eyes > but I'm ready to trade that for speed, if another solution is much faster. >=20 > Thanks a lot, > Ga=EBtan. I prefer the first solution also. You can add or take away liscenses without having to edit a huge amount of data. Be sure you do the right thing with the foreign key. I would leave most of the data handling to postgresql and use php to make it accessable(sp?) in a pretty way.... -Chadwick