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 C2D993A4C21 for ; Sat, 22 Jan 2005 03:00:24 +0000 (GMT) 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 59218-10 for ; Sat, 22 Jan 2005 03:00:10 +0000 (GMT) Received: from sraigw.sra.co.jp (sraigw.sra.co.jp [202.32.10.2]) by svr1.postgresql.org (Postfix) with ESMTP id 424383A4AC0 for ; Sat, 22 Jan 2005 03:00:12 +0000 (GMT) Received: from srascb.sra.co.jp (srascb [133.137.8.65]) by sraigw.sra.co.jp (Postfix) with ESMTP id CBDF463296; Sat, 22 Jan 2005 12:00:11 +0900 (JST) Received: from srascb.sra.co.jp (localhost [127.0.0.1]) by localhost.sra.co.jp (Postfix) with ESMTP id B075F10CD06; Sat, 22 Jan 2005 12:00:11 +0900 (JST) Received: from sranhm.sra.co.jp (sranhm [133.137.44.16]) by srascb.sra.co.jp (Postfix) with ESMTP id 86D9E10CD04; Sat, 22 Jan 2005 12:00:11 +0900 (JST) Received: from localhost (sraihb-hub.sra.co.jp [133.137.8.6]) by sranhm.sra.co.jp (8.9.3+3.2W/3.7W-srambox) with ESMTP id MAA22591; Sat, 22 Jan 2005 12:00:11 +0900 Date: Sat, 22 Jan 2005 12:01:28 +0900 (JST) Message-Id: <20050122.120128.74753619.t-ishii@sra.co.jp> To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org, darcy@wavefire.com, jd@www.commandprompt.com, sfrost@snowman.net, herve@elma.fr Subject: Re: PostgreSQL clustering VS MySQL clustering From: Tatsuo Ishii In-Reply-To: <200501210947.53938.josh@agliodbs.com> References: <200501201949.24292.josh@agliodbs.com> <20050121.170731.08315885.t-ishii@sra.co.jp> <200501210947.53938.josh@agliodbs.com> X-Mailer: Mew version 2.3 on Emacs 20.7 / Mule 4.1 =?iso-2022-jp?B?KBskQjAqGyhCKQ==?= 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, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/405 X-Sequence-Number: 10095 > Tatsuo, > > > Suppose table A gets updated on the master at time 00:00. Until 00:03 > > pgpool needs to send all queries regarding A to the master only. My > > question is, how can pgpool know a query is related to A? > > Well, I'm a little late to head off tangental discussion about this, but .... > > The systems where I've implemented something similar are for web applications. > In the case of the web app, you don't care if a most users see data which is > 2 seconds out of date; with caching and whatnot, it's often much more than > that! > > The one case where it's not permissable for a user to see "old" data is the > case where the user is updating the data. Namely: > > (1) 00:00 User A updates "My Profile" > (2) 00:01 "My Profile" UPDATE finishes executing. > (3) 00:02 User A sees "My Profile" re-displayed > (6) 00:04 "My Profile":UserA cascades to the last Slave server > > So in an application like the above, it would be a real problem if User A were > to get switched over to a slave server immediately after the update; she > would see the old data, assume that her update was not saved, and update > again. Or send angry e-mails to webmaster@. > > However, it makes no difference what User B sees: > > (1) 00:00 User A updates "My Profile"v1 Master > (2) 00:01 "My Profile" UPDATE finishes executing. Master > (3) 00:02 User A sees "My Profile"v2 displayed Master > (4) 00:02 User B requests "MyProfile":UserA Slave2 > (5) 00:03 User B sees "My Profile"v1 Slave2 > (6) 00:04 "My Profile"v2 cascades to the last Slave server Slave2 > > If the web application is structured properly, the fact that UserB is seeing > UserA's information which is 2 seconds old is not a problem (though it might > be for web auctions, where it could result in race conditions. Consider > memcached as a helper). This means that pgPool only needs to monitor > "update switching" by *connection* not by *table*. > > Make sense? I'm not clear what "pgPool only needs to monitor "update switching" by *connection* not by *table*" means. In your example: > (1) 00:00 User A updates "My Profile" > (2) 00:01 "My Profile" UPDATE finishes executing. > (3) 00:02 User A sees "My Profile" re-displayed > (6) 00:04 "My Profile":UserA cascades to the last Slave server I think (2) and (3) are on different connections, thus pgpool cannot judge if SELECT in (3) should go only to the master or not. To solve the problem you need to make pgpool understand "web sessions" not "database connections" and it seems impossible for pgpool to understand "sessions". -- Tatsuo Ishii