X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5383F476182 for ; Sat, 19 Apr 2003 11:58:44 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 8FB9C476128 for ; Sat, 19 Apr 2003 11:58:43 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3JFwmU6021956; Sat, 19 Apr 2003 11:58:48 -0400 (EDT) To: Kevin Brown Cc: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used In-reply-to: <20030419130146.GI1847@filer> References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> Comments: In-reply-to Kevin Brown message dated "Sat, 19 Apr 2003 06:01:46 -0700" Date: Sat, 19 Apr 2003 11:58:48 -0400 Message-ID: <21955.1050767928@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/171 X-Sequence-Number: 1677 Kevin Brown writes: > Josh Berkus wrote: >> They did incorporate a lot of MVCC logic into InnoDB tables, yes. >> Which means that if SELECT count(*) on an InnoDB table is just as >> fast as a MyISAM table, then it is not accurate. > This is not necessarily true. The trigger-based approach to tracking > the current number of rows in a table might well be implemented > internally, and that may actually be much faster than doing it using > triggers You missed the point of Josh's comment: in an MVCC system, the correct COUNT() varies depending on which transaction is asking. Therefore it is not possible for a centrally maintained row counter to give accurate results to everybody, no matter how cheap it is to maintain. (The cheapness can be disputed as well, since it creates a single point of contention for all inserts and deletes on the table. But that's a different topic.) regards, tom lane