[nag] nag_tasks.sql error for PostgreSQL?

Jon Parise jon@horde.org
Mon, 3 Dec 2001 21:16:24 -0500


On Mon, Dec 03, 2001 at 04:35:05PM -0600, Marcus I. Ryan wrote:

> I just installed nag from CVS and went to load the docs/nag_tasks.sql
> file.  It complained about:
>   primary key (task_owner(100), task_id)
> I took out the (100) leaving:
>   primary key (task_owner, task_id)
> and then PostgreSQL would take it.
 
I'm not sure why that was there, either.  I made the change in
cvs. 

-- 
Jon Parise (jon@csh.rit.edu)  .  Information Technology (2001)
http://www.csh.rit.edu/~jon/  :  Computer Science House Member


>From chuck@horde.org Date: Tue,  4 Dec 2001 12:49:04 -0500
Return-Path: <chuck@horde.org>
Mailing-List: contact nag-help@lists.horde.org; run by ezmlm
Delivered-To: mailing list nag@lists.horde.org
Received: (qmail 92176 invoked from network); 4 Dec 2001 17:49:42 -0000
Received: from h00104bc60b3c.ne.mediaone.net (HELO marina.horde.org) (24.91.196.127)
  by clark.horde.org with SMTP; 4 Dec 2001 17:49:42 -0000
Received: by marina.horde.org (Postfix, from userid 33)
	id A89F539D4; Tue,  4 Dec 2001 12:49:04 -0500 (EST)
Received: from 192.168.0.115 ( [192.168.0.115])
	as user chuck@localhost by marina.horde.org with HTTP;
	Tue,  4 Dec 2001 12:49:04 -0500
Message-ID: <1007488144.3c0d0c907988d@marina.horde.org>
Date: Tue,  4 Dec 2001 12:49:04 -0500
From: Chuck Hagenbuch <chuck@horde.org>
To: dev@lists.horde.org
Cc: nag@lists.horde.org
References: <20011204010827.0C77D41C@arkady.horde.org>
In-Reply-To: <20011204010827.0C77D41C@arkady.horde.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 4.0-cvs
Subject: Re: [cvs] cvs commit: nag/docs nag_tasks.sql

Quoting Jon Parise <jon@horde.org>:

>   Remove value after task_owner in primary key.
>   
>   # I have no idea what this was meant to do in the first place.

It only uses the first n characters of the column for the key. So for instance, 
if you have a varchar(255) field, but it's for the most part going to be unique 
in the first 10 characters, then by doing:

create table foo (
  foo_id varchar(255),
  foo_otherinfo varchar(255),
  PRIMARY KEY (foo_id(10), foo_otherinfo(10)
);

... you vastly reduce the size of your indices and speed things up, while 
getting most of the benefit of the key.

I'm having trouble finding a definitive reference at the moment; it might not 
be valid for primary keys. The postgres docs seem a bit sparse; anyone know if 
it takes this syntax in any way (for a key or index instead of a primary key, 
for instance)?

-chuck

--
Charles Hagenbuch, <chuck@horde.org>
"What was and what may be, lie, like children whose faces we cannot see, in the
arms of silence. All we ever have is here, now." - Ursula K. Le Guin