X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 382FE9DD599 for ; Wed, 22 Mar 2006 15:25:51 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20893-09 for ; Wed, 22 Mar 2006 15:25:51 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from isb.com.pl (isb.com.pl [212.160.150.140]) by postgresql.org (Postfix) with ESMTP id 739BD9DD585 for ; Wed, 22 Mar 2006 15:25:48 -0400 (AST) Received: from maciek (sembrz [192.168.1.50]) by isb.com.pl (Postfix) with ESMTP id 02EE857842 for ; Wed, 22 Mar 2006 20:22:25 +0100 (CET) Date: Wed, 22 Mar 2006 20:25:47 +0100 From: Maciej Piekielniak X-Mailer: The Bat! (v1.62r) Reply-To: Maciej Piekielniak X-Priority: 3 (Normal) Message-ID: <121660763.20060322202547@isb.com.pl> To: pgsql-sql@postgresql.org Subject: Re: How to optimize this query? In-Reply-To: <684362e10603221112m3ce21e96x@mail.gmail.com> References: <827987076.20060322181715@isb.com.pl> <684362e10603220958s2dac37cfp@mail.gmail.com> <1731392587.20060322191801@isb.com.pl> <684362e10603221027t354b079bh@mail.gmail.com> <684362e10603221032t4b07f5edu@mail.gmail.com> <672339640.20060322200740@isb.com.pl> <684362e10603221112m3ce21e96x@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] X-Spam-Score: 0.104 X-Spam-Level: X-Archive-Number: 200603/363 X-Sequence-Number: 24709 Hello Markus, Wednesday, March 22, 2006, 8:12:35 PM, you wrote: MB> Well, send the table descriptions, please. \d towar max3 | smallint | default 0 max4 | smallint | default 0 typik | character varying(1) | default '_'::character varying id_grupa_rabatowa | integer | not null default 0 id_jednostka_miary | integer | not null default 0 id_vat | integer | not null default 0 id_typ_towaru | integer | not null default 0 id_dostawcy | integer | not null default 0 grupa_produkcji | smallint | dodatek | boolean | not null default false policzalne | boolean | not null default true simport | character varying(50) | czy_procent | boolean | not null default false subtyp | character varying(35) | kontofk | character varying(40) | typks | character varying(30) | nazwarodzaju | character varying(50) | nazwakatalogu | character varying(250) | waluta | character varying(3) | not null default 'PLN'::character varying bank | character varying(5) | not null default 'NBP'::character varying procent_do_wyceny | smallint | not null default 0 waga | numeric(24,4) | not null default 0 cena_z | numeric(24,4) | not null default 0 ilosc_paczkowa | numeric(24,4) | not null default 0 ilosc_jed | numeric(24,4) | not null default 1 ilosc_nom | numeric(24,4) | not null default 1 odpad | numeric(24,4) | not null default 0 cena_jedn | numeric(24,4) | not null default 0 roboczojednostka | numeric(24,4) | not null default 0 Indexes: "towar_pkey" PRIMARY KEY, btree (id_towar) "towar_key1" btree (key1) "towar_key2" btree (key2) Foreign-key constraints: "$1" FOREIGN KEY (id_grupa_rabatowa) REFERENCES grupa_rabatowa(id_grupa_rabatowa) ON UPDATE CASCADE ON DELETE SET NULL "$2" FOREIGN KEY (id_jednostka_miary) REFERENCES jednostka_miary(id_jednostka_miary) ON UPDATE CASCADE ON DELETE SET NULL "$3" FOREIGN KEY (id_vat) REFERENCES vat(id_vat) ON UPDATE CASCADE ON DELETE SET NULL "$4" FOREIGN KEY (id_typ_towaru) REFERENCES typ_towaru(id_typ_towaru) ON UPDATE CASCADE ON DELETE SET NULL "$5" FOREIGN KEY (id_dostawcy) REFERENCES dostawcy(id_dostawcy) ON UPDATE CASCADE ON DELETE SET NULL Triggers: towar_domyslne BEFORE INSERT ON towar FOR EACH ROW EXECUTE PROCEDURE domyslne_ustawienia() zmiana_wagi AFTER UPDATE ON towar FOR EACH ROW EXECUTE PROCEDURE waga_przelicz() -- Best regards, Maciej mailto:piechcio@isb.com.pl