From o.haro@en-compro.com Tue Aug 17 13:30:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A74115E40BB for ; Tue, 17 Aug 2004 10:30:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69463-04 for ; Tue, 17 Aug 2004 13:30:28 +0000 (GMT) Received: from mail.aspserveur.com (7.95.39-62.rev.gaoland.net [62.39.95.7]) by svr1.postgresql.org (Postfix) with ESMTP id 1F4695E3639 for ; Tue, 17 Aug 2004 10:30:25 -0300 (ADT) Received: from saturne ([193.251.84.117]) by mail.aspserveur.com (ASPSERVEUR Ultimate mail Server) with SMTP id HUO74536 for ; Tue, 17 Aug 2004 15:30:55 +0200 Message-ID: <002901c4845e$5d1dc1c0$0c0101c0@saturne> From: "olivier HARO" To: Subject: General performance problem! Date: Tue, 17 Aug 2004 15:30:29 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0026_01C4846F.203A1450" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=HTML_30_40, HTML_FONTCOLOR_BLUE, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200408/253 X-Sequence-Number: 7889 This is a multi-part message in MIME format. ------=_NextPart_000_0026_01C4846F.203A1450 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I have a dedicated server for my posgresql database : P4 2.4 GHZ HDD IDE 7200 rpm 512 DDR 2700 I have a problem whith one table of my database : CREATE SEQUENCE "base_aveugle_seq" START 1; CREATE TABLE "base_aveugle" ( "record_id" integer DEFAULT nextval('"base_aveugle_seq"'::text) NOT NULL, "dunsnumber" integer NOT NULL, "cp" text NOT NULL, "tel" text NOT NULL, "fax" text NOT NULL, "naf" text NOT NULL, "siege/ets" text NOT NULL, "effectif" integer NOT NULL, "ca" integer NOT NULL, Constraint "base_aveugle_pkey" Primary Key ("record_id") ); CREATE INDEX base_aveugle_dunsnumber_key ON base_aveugle USING btree (dunsn= umber); CREATE INDEX base_aveugle_cp_key ON base_aveugle USING btree (cp); CREATE INDEX base_aveugle_naf_key ON base_aveugle USING btree (naf); CREATE INDEX base_aveugle_effectif_key ON base_aveugle USING btree (effecti= f); This table contains 5 000 000 records I have a PHP application which often makes queries on this table (especiall= y on the "cp","naf","effectif" fields) Querries are like : select (distint cp) from base_aveugle where cp=3D'201A' and effectif = between 1 and 150 select (*) from base_aveugle where naf in ('721A','213F','421K') and = cp in ('54210','21459','201A') and effectif < 150 I think it is possible to optimize the performance of this queries before c= hanging the hardware (I now I will...) but I don't know how, even after hav= ing read lot of things about postgresql ... Thanks ;)=20 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004 ------=_NextPart_000_0026_01C4846F.203A1450 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello,
 
I have a dedicated serve= r for my=20 posgresql database :
 
P4 2.4 GHZ
HDD IDE 7200 rpm<= /DIV>
512 DDR 2700
 
I have a problem whith o= ne table of=20 my database :
 
CREATE SEQUENCE "base_aveugle_seq" START= =20 1;
CREATE TABLE "base_aveugle" (
 "record_id" integer DEFAULT=20 nextval('"base_aveugle_seq"'::text) NOT NULL,
 "dunsnumber" integer= NOT=20 NULL,
 "cp" text NOT NULL,
 "tel" text NOT NULL,
 "= fax"=20 text NOT NULL,
 "naf" text NOT NULL,
 "siege/ets" text NOT= =20 NULL,
 "effectif" integer NOT NULL,
 "ca" integer NOT=20 NULL,
 Constraint "base_aveugle_pkey" Primary Key=20 ("record_id")
);
CREATE INDEX base_aveugle_dunsnumber_key ON base_ave= ugle=20 USING btree (dunsnumber);
CREATE INDEX base_aveugle_cp_key ON base_aveug= le=20 USING btree (cp);
CREATE INDEX base_aveugle_naf_key ON base_aveugle USIN= G=20 btree (naf);
CREATE INDEX base_aveugle_effectif_key ON base_aveugle USIN= G=20 btree (effectif);
 
 
This table contains 5 00= 0 000=20 records
 
I have a PHP application= which=20 often makes queries on this table (especially on the "cp","naf","effectif"= =20 fields)
 
Querries are like :
    =  =20 select (distint cp) from base_aveugle where cp=3D'201A' and effectif betwee= n 1 and=20 150
    =  =20 select (*) from base_aveugle where naf in ('721A','213F','421K') and cp in= =20 ('54210','21459','201A') and effectif < 150
 
I think it is possible t= o optimize=20 the performance of this queries before changing the hardware (I now I= =20 will...) but I don't know how, even after having read lot of things about= =20 postgresql ...
 
Thanks ;) 
 

---
Outgoing mail= is=20 certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.= 0.737 /=20 Virus Database: 491 - Release Date: 11/08/2004
------=_NextPart_000_0026_01C4846F.203A1450-- From mendola@bigfoot.com Tue Aug 17 14:12:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A11C45E46EF for ; Tue, 17 Aug 2004 11:12:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85710-10 for ; Tue, 17 Aug 2004 14:12:24 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id BFBA95E46CC for ; Tue, 17 Aug 2004 11:12:21 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i7HECMiI090585 for ; Tue, 17 Aug 2004 14:12:22 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i7HDmQF7078750 for pgsql-performance@postgresql.org; Tue, 17 Aug 2004 13:48:26 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.performance Subject: Re: General performance problem! Date: Tue, 17 Aug 2004 15:48:29 +0200 Organization: PYRENET Midi-pyrenees Provider Lines: 62 Message-ID: <41220CAD.60401@bigfoot.com> References: <002901c4845e$5d1dc1c0$0c0101c0@saturne> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@pyrenet.fr To: olivier HARO User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en In-Reply-To: <002901c4845e$5d1dc1c0$0c0101c0@saturne> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/255 X-Sequence-Number: 7891 olivier HARO wrote: > Hello, > > I have a dedicated server for my posgresql database : > > P4 2.4 GHZ > HDD IDE 7200 rpm > 512 DDR 2700 > > I have a problem whith one table of my database : > > CREATE SEQUENCE "base_aveugle_seq" START 1; > CREATE TABLE "base_aveugle" ( > "record_id" integer DEFAULT nextval('"base_aveugle_seq"'::text) NOT NULL, > "dunsnumber" integer NOT NULL, > "cp" text NOT NULL, > "tel" text NOT NULL, > "fax" text NOT NULL, > "naf" text NOT NULL, > "siege/ets" text NOT NULL, > "effectif" integer NOT NULL, > "ca" integer NOT NULL, > Constraint "base_aveugle_pkey" Primary Key ("record_id") > ); > CREATE INDEX base_aveugle_dunsnumber_key ON base_aveugle USING btree > (dunsnumber); > CREATE INDEX base_aveugle_cp_key ON base_aveugle USING btree (cp); > CREATE INDEX base_aveugle_naf_key ON base_aveugle USING btree (naf); > CREATE INDEX base_aveugle_effectif_key ON base_aveugle USING btree > (effectif); > > > This table contains 5 000 000 records > > I have a PHP application which often makes queries on this table > (especially on the "cp","naf","effectif" fields) > > Querries are like : > select (distint cp) from base_aveugle where cp='201A' and effectif > between 1 and 150 > select (*) from base_aveugle where naf in ('721A','213F','421K') > and cp in ('54210','21459','201A') and effectif < 150 > > I think it is possible to optimize the performance of this queries > before changing the hardware (I now I will...) but I don't know how, > even after having read lot of things about postgresql ... Show us a explain analyze for that queries. Regards Gaetano Mendola From tim.leeuwvander@nl.unisys.com Tue Aug 17 13:57:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0E4295E37CE for ; Tue, 17 Aug 2004 10:57:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80061-07 for ; Tue, 17 Aug 2004 13:57:31 +0000 (GMT) Received: from usbb-lacimss3.unisys.com (usbb-lacimss3.unisys.com [192.63.108.53]) by svr1.postgresql.org (Postfix) with ESMTP id 882EF5E37CB for ; Tue, 17 Aug 2004 10:57:27 -0300 (ADT) Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.43]unverified) by usbb-lacimss3 with InterScan Messaging Security Suite; Tue, 17 Aug 2004 09:59:27 -0400 Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.44]) by USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); Tue, 17 Aug 2004 09:57:28 -0400 Received: from gbmk-eugw2.eu.uis.unisys.com ([129.221.133.27]) by USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); Tue, 17 Aug 2004 09:57:28 -0400 Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by gbmk-eugw2.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); Tue, 17 Aug 2004 14:57:25 +0100 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C48462.2017A1BC" X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Subject: Re: General performance problem! Date: Tue, 17 Aug 2004 15:57:25 +0200 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] General performance problem! Thread-Index: AcSEXqt1Qqu7d/JVRsur69d01UsjfAAAskMA From: "Leeuw van der, Tim" To: "olivier HARO" , X-OriginalArrivalTime: 17 Aug 2004 13:57:25.0790 (UTC) FILETIME=[205DDBE0:01C48462] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=HTML_30_40, HTML_FONTCOLOR_BLUE, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200408/254 X-Sequence-Number: 7890 This is a multi-part message in MIME format. ------_=_NextPart_001_01C48462.2017A1BC Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, =20 Make multi-column indexes, using the columns from your most typical queries= , putting the most selective columns first (ie; you don't need to make inde= xes with columns in the same order as they are used in the query). =20 For instance, an index on cp, effectif could likely benefit both queries; s= ame for an index on cp, effectif, naf. (You'd need only one of these indexe= s I think, not both. Experiment to find out which one gives you most benefi= t in your queries, vs. the slowdown in inserts). Perhaps some of the single-column keys can be dropped. =20 -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owne= r@postgresql.org]On Behalf Of olivier HARO Sent: dinsdag 17 augustus 2004 15:30 To: pgsql-performance@postgresql.org Subject: [PERFORM] General performance problem! Hello, =20 I have a dedicated server for my posgresql database : =20 P4 2.4 GHZ HDD IDE 7200 rpm 512 DDR 2700 =20 I have a problem whith one table of my database : =20 CREATE SEQUENCE "base_aveugle_seq" START 1; CREATE TABLE "base_aveugle" ( "record_id" integer DEFAULT nextval('"base_aveugle_seq"'::text) NOT NULL, "dunsnumber" integer NOT NULL, "cp" text NOT NULL, "tel" text NOT NULL, "fax" text NOT NULL, "naf" text NOT NULL, "siege/ets" text NOT NULL, "effectif" integer NOT NULL, "ca" integer NOT NULL, Constraint "base_aveugle_pkey" Primary Key ("record_id") ); CREATE INDEX base_aveugle_dunsnumber_key ON base_aveugle USING btree (dunsn= umber); CREATE INDEX base_aveugle_cp_key ON base_aveugle USING btree (cp); CREATE INDEX base_aveugle_naf_key ON base_aveugle USING btree (naf); CREATE INDEX base_aveugle_effectif_key ON base_aveugle USING btree (effecti= f); =20 =20 This table contains 5 000 000 records =20 I have a PHP application which often makes queries on this table (especiall= y on the "cp","naf","effectif" fields) =20 Querries are like : select (distint cp) from base_aveugle where cp=3D'201A' and effectif = between 1 and 150 select (*) from base_aveugle where naf in ('721A','213F','421K') and = cp in ('54210','21459','201A') and effectif < 150 =20 I think it is possible to optimize the performance of this queries before c= hanging the hardware (I now I will...) but I don't know how, even after hav= ing read lot of things about postgresql ... =20 Thanks ;)=20 =20 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system ( http://www.grisoft.com). Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004 ------_=_NextPart_001_01C48462.2017A1BC Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
Make=20 multi-column indexes, using the columns from your most typical queries, put= ting=20 the most selective columns first (ie; you don't need to make indexes with= =20 columns in the same order as they are used in the query).
 
For=20 instance, an index on cp, effectif could likely benefit both queries; same = for=20 an index on cp, effectif, naf. (You'd need only one of these indexes I thin= k,=20 not both. Experiment to find out which one gives you most benefit in your= =20 queries, vs. the slowdown in inserts).
Perhaps some of the single-column keys can be=20 dropped.
 
-----Original Message-----
From:=20 pgsql-performance-owner@postgresql.org=20 [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of olivie= r=20 HARO
Sent: dinsdag 17 augustus 2004 15:30
To:=20 pgsql-performance@postgresql.org
Subject: [PERFORM] General=20 performance problem!

Hello,
 
I have a dedicated ser= ver for my=20 posgresql database :
 
P4 2.4 GHZ
HDD IDE 7200 rpm
512 DDR 2700
 
I have a problem whith= one table=20 of my database :
 
CREATE SEQUENCE "base_aveugle_seq" STA= RT=20 1;
CREATE TABLE "base_aveugle" (
 "record_id" integer DEFAULT= =20 nextval('"base_aveugle_seq"'::text) NOT NULL,
 "dunsnumber" integ= er=20 NOT NULL,
 "cp" text NOT NULL,
 "tel" text NOT=20 NULL,
 "fax" text NOT NULL,
 "naf" text NOT=20 NULL,
 "siege/ets" text NOT NULL,
 "effectif" integer NOT= =20 NULL,
 "ca" integer NOT NULL,
 Constraint "base_aveugle_p= key"=20 Primary Key ("record_id")
);
CREATE INDEX base_aveugle_dunsnumber_k= ey ON=20 base_aveugle USING btree (dunsnumber);
CREATE INDEX base_aveugle_cp_ke= y ON=20 base_aveugle USING btree (cp);
CREATE INDEX base_aveugle_naf_key ON=20 base_aveugle USING btree (naf);
CREATE INDEX base_aveugle_effectif_key= ON=20 base_aveugle USING btree (effectif);
 
 
This table contains 5 = 000 000=20 records
 
I have a PHP applicati= on which=20 often makes queries on this table (especially on the "cp","naf","effectif= "=20 fields)
 
Querries are like :
   &nbs= p; =20 select (distint cp) from base_aveugle where cp=3D'201A' and effectif betw= een 1=20 and 150
   &nbs= p; =20 select (*) from base_aveugle where naf in ('721A','213F','421K') and cp i= n=20 ('54210','21459','201A') and effectif < 150
 
I think it is possible= to=20 optimize the performance of this queries before changing the hardwar= e (I=20 now I will...) but I don't know how, even after having read lot of things= =20 about postgresql ...
 
Thanks ;) =
 

---
Outgoing ma= il is=20 certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: = 6.0.737=20 / Virus Database: 491 - Release Date:=20 11/08/2004
------_=_NextPart_001_01C48462.2017A1BC-- From dev@archonet.com Tue Aug 17 14:16:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E0F265E46ED for ; Tue, 17 Aug 2004 11:16:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91444-03 for ; Tue, 17 Aug 2004 14:16:16 +0000 (GMT) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by svr1.postgresql.org (Postfix) with ESMTP id 312855E46EC for ; Tue, 17 Aug 2004 11:16:13 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 1Bx4l8-0002RN-0W; Tue, 17 Aug 2004 14:16:19 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 5608418658; Tue, 17 Aug 2004 15:16:16 +0100 (BST) Message-ID: <4122132E.80603@archonet.com> Date: Tue, 17 Aug 2004 15:16:14 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: olivier HARO Cc: pgsql-performance@postgresql.org Subject: Re: General performance problem! References: <002901c4845e$5d1dc1c0$0c0101c0@saturne> In-Reply-To: <002901c4845e$5d1dc1c0$0c0101c0@saturne> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/256 X-Sequence-Number: 7892 olivier HARO wrote: > This table contains 5 000 000 records > > I have a PHP application which often makes queries on this table (especially on the "cp","naf","effectif" fields) > > Querries are like : > select (distint cp) from base_aveugle where cp='201A' and effectif between 1 and 150 > select (*) from base_aveugle where naf in ('721A','213F','421K') and cp in ('54210','21459','201A') and effectif < 150 We'll need to know what version of PostgreSQL you're using and also what the output of EXPLAIN ANALYZE shows for your example queries. -- Richard Huxton Archonet Ltd From o.haro@en-compro.com Tue Aug 17 15:41:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CB73E5E46E9 for ; Tue, 17 Aug 2004 12:41:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33456-06 for ; Tue, 17 Aug 2004 15:41:45 +0000 (GMT) Received: from mail.aspserveur.com (7.95.39-62.rev.gaoland.net [62.39.95.7]) by svr1.postgresql.org (Postfix) with ESMTP id 4FD975E46E2 for ; Tue, 17 Aug 2004 12:41:35 -0300 (ADT) Received: from saturne ([193.251.84.117]) by mail.aspserveur.com (ASPSERVEUR Ultimate mail Server) with SMTP id HUO74536 for ; Tue, 17 Aug 2004 17:42:08 +0200 Message-ID: <001901c48470$b1b92140$0c0101c0@saturne> From: "olivier HARO" To: Subject: Re: General performance problem! Date: Tue, 17 Aug 2004 17:41:41 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/258 X-Sequence-Number: 7894 Thanks for the tip for the index on multiple columns ! (I never do inserts on this table so insert time doesn't matter) Mys posgresql version is : PostgreSQL 7.2.1 Here are the results of the EXPLAIN ANALYZE you asked me to execute. explain analyse select cp from base_aveugle where cp='69740' and effectif between 1 and 50; NOTICE: QUERY PLAN: Index Scan using base_aveugle_cp_eff on base_aveugle (cost=0.00..508.69 rows=126 width=32) (actual time=0.27..11.56 rows=398 loops=1) Total runtime: 11.77 msec EXPLAIN explain analyse select cp from base_aveugle where cp like '69%' and effectif between 1 and 50 and naf like '24%' or naf like '25%'; NOTICE: QUERY PLAN: Index Scan using base_aveugle_cp_eff_naf, base_aveugle_naf on base_aveugle (cost=0.00..100001.89 rows=25245 width=32) (actual time=4.40..353.69 rows=6905 loops=1) Total runtime: 355.82 msec EXPLAIN thx ;) --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004 From DLee@mail.maricopa.gov Tue Aug 17 16:59:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E558F5E40BB for ; Tue, 17 Aug 2004 13:59:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62480-10 for ; Tue, 17 Aug 2004 16:59:09 +0000 (GMT) Received: from mailbox.maricopa.gov (mailbox.maricopa.gov [156.42.4.109]) by svr1.postgresql.org (Postfix) with ESMTP id DA45C5E37CE for ; Tue, 17 Aug 2004 13:58:59 -0300 (ADT) Received: from maricopa_xcng2.maricopa.gov (maricopa_xcng2.maricopa.gov [156.42.103.174] (may be forged)) by mailbox.maricopa.gov (8.8.6 (PHNE_17190)/8.8.6) with ESMTP id JAA05820; Tue, 17 Aug 2004 09:51:47 -0700 (MST) Received: by maricopa_xcng2 with Internet Mail Service (5.5.2657.72) id ; Tue, 17 Aug 2004 09:59:00 -0700 Message-ID: <64EDC403A1417B4299488BAE87CA7CBF01CD0F36@maricopa_xcng0> From: Duane Lee - EGOVX To: "'olivier HARO'" , pgsql-performance@postgresql.org Subject: Re: General performance problem! Date: Tue, 17 Aug 2004 09:58:59 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2657.72) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C4847B.7DBF4F30" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_70_80, HTML_FONTCOLOR_UNKNOWN, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200408/260 X-Sequence-Number: 7896 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C4847B.7DBF4F30 Content-Type: text/plain; charset="iso-8859-1" An index on cp and effectif would help your first query. An index on naf, cp and effectif would help your second query. Something like this: CREATE INDEX base_aveugle_cp_key2 ON base_aveugle USING btree (cp, effectif); CREATE INDEX base_aveugle_naf_key2 ON base_aveugle USING btree (naf, cp, effectif); Another thing, why include "distinct cp" when you are only selecting "cp='201A'"? You will only retrieve one record regardless of how many may contain cp='201A'. If you could make these UNIQUE indexes that would help also but it's not a requirement. Good luck, Duane -----Original Message----- From: olivier HARO [mailto:o.haro@en-compro.com] Sent: Tuesday, August 17, 2004 6:30 AM To: pgsql-performance@postgresql.org Subject: [PERFORM] General performance problem! Hello, I have a dedicated server for my posgresql database : P4 2.4 GHZ HDD IDE 7200 rpm 512 DDR 2700 I have a problem whith one table of my database : CREATE SEQUENCE "base_aveugle_seq" START 1; CREATE TABLE "base_aveugle" ( "record_id" integer DEFAULT nextval('"base_aveugle_seq"'::text) NOT NULL, "dunsnumber" integer NOT NULL, "cp" text NOT NULL, "tel" text NOT NULL, "fax" text NOT NULL, "naf" text NOT NULL, "siege/ets" text NOT NULL, "effectif" integer NOT NULL, "ca" integer NOT NULL, Constraint "base_aveugle_pkey" Primary Key ("record_id") ); CREATE INDEX base_aveugle_dunsnumber_key ON base_aveugle USING btree (dunsnumber); CREATE INDEX base_aveugle_cp_key ON base_aveugle USING btree (cp); CREATE INDEX base_aveugle_naf_key ON base_aveugle USING btree (naf); CREATE INDEX base_aveugle_effectif_key ON base_aveugle USING btree (effectif); This table contains 5 000 000 records I have a PHP application which often makes queries on this table (especially on the "cp","naf","effectif" fields) Querries are like : select (distint cp) from base_aveugle where cp='201A' and effectif between 1 and 150 select (*) from base_aveugle where naf in ('721A','213F','421K') and cp in ('54210','21459','201A') and effectif < 150 I think it is possible to optimize the performance of this queries before changing the hardware (I now I will...) but I don't know how, even after having read lot of things about postgresql ... Thanks ;) --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system ( http://www.grisoft.com ). Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004 ------_=_NextPart_001_01C4847B.7DBF4F30 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable   An index on naf, cp and effectif would help your second query.

 

Some= thing like this:

 

CREATE INDEX base_aveugle_cp_key2 ON base_aveugle USING btree (cp, effectif);
CREATE INDEX base_aveugle_naf_key2 ON base_aveugle USING btree (naf, cp, effectif);

 

<= span style=3D'font-size:12.0pt;color:navy'>Another thing, why include “dis= tinct cp” when you are only selecting “cp=3D’201A’”?  You will only retrieve one record regardless of how many may contain= cp=3D’201A’.

<= span style=3D'font-size:12.0pt;color:navy'> 

<= span style=3D'font-size:12.0pt;color:navy'>If you could make these UNIQUE indexe= s that would help also but it’s not a requirement.

 

Good= luck,

Duan= e

 

 

-----Original Message-----
From: olivier HARO [mailto:o.haro@en-compro.com]
Sent: Tuesday, August 17, 20= 04 6:30 AM
To: pgsql-performance@postgresql.org
Subject: [PERFORM] General performance problem!

 <= /o:p>

Hello,

 = ;

I have a dedicated server for my posgresql database :

 = ;

P4 2.4 GHZ

HDD IDE 7200 rpm

512 DDR 2700

 = ;

I have a problem whith one table of my database :

 = ;

CREATE SEQUENCE "base_aveugle_seq" START 1;
CREATE TABLE "base_aveugle" (
 "record_id" integer DEFAULT nextval('"base_aveugle_seq"'::text) NOT NULL,
 "dunsnumber" integer NOT NULL,
 "cp" text NOT NULL,
 "tel" text NOT NULL,
 "fax" text NOT NULL,
 "naf" text NOT NULL,
 "siege/ets" text NOT NULL,
 "effectif" integer NOT NULL,
 "ca" integer NOT NULL,
 Constraint "base_aveugle_pkey" Primary Key ("record_id")
);
CREATE INDEX base_aveugle_dunsnumber_key ON base_aveugle USING btree (dunsnumber);
CREATE INDEX base_aveugle_cp_key ON base_aveugle USING btree (cp);
CREATE INDEX base_aveugle_naf_key ON base_aveugle USING btree (naf);
CREATE INDEX base_aveugle_effectif_key ON base_aveugle USING btree (effecti= f);

 = ;

 = ;

This table contains 5 000 000 records

 = ;

I have a PHP application which often makes queries on this table (especially = on the "cp","naf","effectif" fields)

 = ;

Querries are like :

      select (distint cp) from base_aveugle where cp=3D'201A' and effectif betwee= n 1 and 150

      select (*) from base_aveugle where naf in ('721A','213F','421K') and cp in ('54210','21459','201A') and effectif < 150

 = ;

I think it is possible to optimize the performance of this queries before changing the hardware (I now I will...) but I don't know how, even aft= er having read lot of things about postgresql ...

 = ;

Thanks ;) 

 = ;


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http:/= /www.grisoft.com).
Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004

------_=_NextPart_001_01C4847B.7DBF4F30--