Re: Simple PHP/pgsql optimization question...

From: Keary Suska <hierophant(at)pcisys(dot)net>
To: Postgres-PHP <pgsql-php(at)postgresql(dot)org>
Subject: Re: Simple PHP/pgsql optimization question...
Date: 2002-05-18 18:10:11
Message-ID: B90BF523.E93A%hierophant@pcisys.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

on 5/18/02 9:14 AM, ged(at)bugfactory(dot)org purportedly said:

> In my 'projects' tables, among many other fields, I need a 'license' field.
> 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?
>
> 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=license.id and ...
>
> 2) Have the license field in the 'projects' table be a varchar field and
> store the name of the license directly.
>
> 3) Have the license field be an int and have an array in PHP listing all the
> licenses.
>
> 4) another solution?

The main issue is the relationship between licenses and projects. Can there
be more than one license per project, or multiple projects per license, or
both? Or is there only one license per project? Only in this last case is it
advisable to have the license field in the project table. Data integrity
should never be sacrificed for any reason, even speed. But if you are
talking about hundreds of records, you should not notice any speed
difference regardless of how you implement it, at least as far as Postgres
is concerned.

Your solution #1 works properly only if there are multiple projects per
license, and is the best solution in that case.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Keary Suska 2002-05-18 18:32:35 Re: using CURSOR with PHP
Previous Message Chadwick Rolfs 2002-05-18 15:47:38 Re: Simple PHP/pgsql optimization question...