Received: from fslc.usu.edu (fslc.usu.edu [129.123.2.40]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f2IFpxx34397 for ; Sun, 18 Mar 2001 10:51:59 -0500 (EST) (envelope-from rmello@fslc.usu.edu) Received: (from rmello@localhost) by fslc.usu.edu (8.11.3/8.11.3/Debian 8.11.2-1) id f2IFpsX10467 for pgsql-docs@postgresql.org; Sun, 18 Mar 2001 08:51:54 -0700 Date: Sun, 18 Mar 2001 08:51:54 -0700 From: Roberto Mello To: pgsql-docs@postgresql.org Subject: Re: [SQL] Select very slow... Message-ID: <20010318085154.B10431@cc.usu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.15i X-Archive-Number: 200103/82 X-Sequence-Number: 515 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?