Re: [SQL] Select very slow...

From: Roberto Mello <rmello(at)cc(dot)usu(dot)edu>
To: pgsql-docs(at)postgresql(dot)org
Subject: Re: [SQL] Select very slow...
Date: 2001-03-18 15:51:54
Message-ID: 20010318085154.B10431@cc.usu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs


On Sun, Mar 18, 2001 at 06:15:42AM -0300, Fernando Eduardo B. L. e Carvalho wrote:
>
> Table 1
>
> create table person (
>
> doc text primary key,
^^^^^^^^^^^^^^^^

The "text" datatype is for columns that usually will store big text
segments. It's not a good idea to put this as primary key (which implies
that there can never be two equal "doc" records).
It would be better if you had something like "person_id integer
primary key" or "person_id serial primary key".
What's stored in the "doc" column?

> select p.city,count(*) from sales s, person p where s.doc = p.doc
> group by p.city;

If you have big chunks of text in the doc column, PG has look for a
match in these two columns. If you give us more details on what you are
trying to do, we could help more.
Se voce fala portugues, eu posso responder em portugues tambem.

-Roberto
--
+----| http://fslc.usu.edu USU Free Software & GNU/Linux Club|------+
Roberto Mello - Computer Science, USU - http://www.brasileiro.net
http://www.sdl.usu.edu - Space Dynamics Lab, Web Developer
H y! Wh r did my " " k y go?

Browse pgsql-docs by date

  From Date Subject
Next Message Björn Lundin 2001-03-18 20:23:20 Error in programer's guide JDBC chap 23
Previous Message jreniz 2001-03-17 05:22:44 Trigger problem