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 D57AF528C3 for ; Tue, 28 Jun 2005 00:34:03 -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 96432-03 for ; Tue, 28 Jun 2005 03:33:59 +0000 (GMT) Received: from smtp008.bizmail.sc5.yahoo.com (smtp008.bizmail.sc5.yahoo.com [66.163.170.74]) by svr1.postgresql.org (Postfix) with SMTP id DA8895288B for ; Tue, 28 Jun 2005 00:33:58 -0300 (ADT) Received: from unknown (HELO ?192.168.3.41?) (david.mitchell@telogis.com@203.98.10.169 with plain) by smtp008.bizmail.sc5.yahoo.com with SMTP; 28 Jun 2005 03:33:52 -0000 Message-ID: <42C0C518.4020109@telogis.com> Date: Tue, 28 Jun 2005 15:33:44 +1200 From: David Mitchell User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: KeithW@NarrowPathInc.com Cc: pgsql-performance@postgresql.org Subject: Re: How can I speed up this function? References: <42C0B7EE.4040608@telogis.com> <42C0C226.8070201@NarrowPathInc.com> In-Reply-To: <42C0C226.8070201@NarrowPathInc.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200506/524 X-Sequence-Number: 13161 Hi Keith, Unfortunately, we must have those sorts. The statements within a transaction must be executed on the slave in the same order as they were on the master, and similarly, transactions must also go in the same order. As for aliasing the tables, that is just a remnant from previous versions of the code. Thanks David Keith Worthington wrote: > I'm still a newbie and it may not affect performance but why are you > aliasing the tables? Can you not simply use > > FOR transaction IN SELECT trans_id > FROM pending_trans > WHERE fetched = false > ORDER BY trans_id > LIMIT 50 > > and > > FOR statement IN SELECT id, > transaction_id, > table_name, > op, > data > FROM dbmirror.pending_statement > WHERE pending_statement.transaction_id = > transaction.trans_id > ORDER BY pending_statement.id > > I am pretty sure that the ORDER BY is slowing down both of these > queries. Since you are going to go through the whole table eventually > do you really need to sort the data at this point? > -- David Mitchell Software Engineer Telogis