Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ADC29475DA3 for ; Tue, 15 Oct 2002 09:03:46 -0400 (EDT) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 3E8D2475BC3 for ; Tue, 15 Oct 2002 09:03:46 -0400 (EDT) Received: by news.hub.org (Postfix, from userid 8) id 9921338167B; Tue, 15 Oct 2002 09:03:43 -0400 (EDT) From: "Gaetano Mendola" X-Newsgroups: comp.databases.postgresql.general, comp.databases.postgresql.questions Subject: Re: query optimization Date: Tue, 15 Oct 2002 15:03:45 +0200 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 51 Message-ID: References: <3DABBE6F.67930574@t1.unisoftbg.com> X-Complaints-To: news@hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 To: pgsql-general@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/670 X-Sequence-Number: 31668 > > The query is and the explain analyze are: > > testsklad19=# explain analyze select > N.IDS,N.IDS_NUM,N.IDS_SLU,N.IDS_SKLAD,SK.MNAME AS > SKNAME,N.ZAPR,N.NOMNUM,NOM.NUM,N.NOMNAME,NOM.MNAME AS > NOMNAME,N.PART,N.SERIENNUM,N.IZV,N.KOL,N.IDS_MED,N.MED,N.IDS_MED_MAIN,N.MED_ MAIN,N.OTN_MED,N.CENA,N.VAL,N.KURS,N.CENADDS,N.DDS,N.CENA_LV,N.CENA_LVDDS,N. TOT,N.DTO,N.PTO,N.ORDER_NUM,N.IDS_DOC2,NOM.OSN_MED,NOM.DOP1_MED,NOM.DOP2_MED ,NOM.OTN_DOP1_MED,NOM.OTN_DOP2_MED,N.DTON > ,N.OFFIC,N.DATE_IZL,N.IZL,N.OTCH_CENA,N.CENAMITALV,N.CENATAKSILV,N.CENATRANS LV,N.CENA,N.CENAZASTRLV > from A_SKLAD N left outer join A_LOCATION SK ON ( N.IDS_SKLAD=SK.IDS ) > left outer join A_NOMEN NOM ON ( N.IDS_NUM = NOM.IDS ) where N.FID = 0 > AND N.IDS_DOC = 'SOF_500' ORDER BY N.ORDER_NUM ; > NOTICE: QUERY PLAN: > Well, can you tell us the index that are present on table A_SKLAD ? It seem that there are no index on the field FID, BTW if for you are always important only the line whit FID = 0 ( or other few values ) you can create a partial index: CREATE INDEX idx_partial ON a_sklad ( fid ) WHERE FID = 0; or if the values are more: CREATE INDEX idx_partial ON a_sklad ( fid ) WHERE FID IN ( val1, val2, .... ); Dont forget to do: 'vacuum analyze a_skland' after index creation. Good luck Gaetano