X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1E9BB52868 for ; Sun, 22 May 2005 05:16:06 -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 31411-03 for ; Sun, 22 May 2005 08:15:56 +0000 (GMT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.186]) by svr1.postgresql.org (Postfix) with ESMTP id 778F252861 for ; Sun, 22 May 2005 05:15:54 -0300 (ADT) Received: from [194.25.154.138] (helo=webserv.wug.de) by mrelayeu.kundenserver.de with ESMTP (Nemesis), id 0ML2Dk-1DZldS2pLa-0006H3; Sun, 22 May 2005 10:16:34 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.35 #1) id 1DZlej-0001OS-00 for pgsql-sql@postgresql.org; Sun, 22 May 2005 10:17:53 +0200 Date: Sun, 22 May 2005 10:17:53 +0200 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: [despammed] Balance Calculation Message-ID: <20050522081753.GA5136@webserv.wug-glas.de> Mail-Followup-To: Andreas Kretschmer , pgsql-sql@postgresql.org References: <033001c55e85$1801a730$1f00a8c0@middinks> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <033001c55e85$1801a730$1f00a8c0@middinks> X-DEST: 208 X-MSMail-Priority: High X-Message-Flag: The Windows platform is not just insecure - it's patently, blatantly, and unashamedly insecure by design. X-PrivatMail: kretschmer@kaufbach.delug.de X-OS: Linux - weil ich es mir Wert bin! X-Info: registrierter Linux-User 97922 http://counter.li.org User-Agent: mutt-ng 1.5.9i (Linux) X-Provags-ID: kundenserver.de abuse@kundenserver.de login:51ea9561fc3f6d9539a2acd743e4748c X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.327 tagged_above=0 required=5 tests=AWL, MISSING_MIMEOLE, X_MSMAIL_PRIORITY_HIGH X-Spam-Level: X-Archive-Number: 200505/176 X-Sequence-Number: 21489 am 22.05.2005, um 12:15:56 +0800 mailte Muhyiddin A.M Hayat folgendes: Nice SQL ;-) > > everything is ok, but when record > 1000000 that query eat all my cpu > process and take a long time, i have wait for 3 mimutes but query I think, because for every record in your result is a full table scan required to calculate the balance. > > can you help me how to fix them. > Can I using function to fix them (how?) It is possible to create a extra table for the balance and a trigger for insert/update that calculates the balance for the transactions-table? I think, this should solve your perfomance-problem. Regards, Andreas -- Andreas Kretschmer (Kontakt: siehe Header) Heynitz: 035242/47212, D1: 0160/7141639 GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net === Schollglas Unternehmensgruppe ===