Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 32003475C15 for ; Sat, 4 Jan 2003 08:33:16 -0500 (EST) Received: from albert.auore.net (80-24-20-197.uc.nombres.ttd.es [80.24.20.197]) by postgresql.org (Postfix) with SMTP id C0D0147590C for ; Sat, 4 Jan 2003 08:33:13 -0500 (EST) Received: (qmail 1772 invoked by uid 1000); 4 Jan 2003 13:31:51 -0000 From: Albert Cervera Areny Subject: Fwd: Stock update like application Date: Sat, 4 Jan 2003 14:31:51 +0100 User-Agent: KMail/1.5 To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200301041431.51423.albertca@jazzfree.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/30 X-Sequence-Number: 677 Hi! I'm developing a small application which I'd like to be as fast as possible. The program simply receives an order by modem and has to give an answer with the products my enterprise will be able to send them. The number of products could be as much as 300-400 and I don't want to make my clients put I high time-out before the answer is sended. I do also need to use transactions as I start calculating before the whole order has been received and if an error occurs everything has to be rolled back. Under this circumstances which way do you think it would be faster? - Make a sequence for each product (we're talking about 20000 available products so I think it is very big but it might give a really fast answer). - Using standard SQL queries: SELECT the product, and if there are enough units UPDATE to decrease the number of available ones. (This one I suppose it's not very fast as two queries need to be processed for each product). - Using a CURSOR or something like this which I'm not used to but I've seen in the examples. Should I have the queries saved in the database to encrease performance? I hope I explained well enough :-) Thanks in advance!