From: Sergei Golubchik Date: January 9 2011 3:41pm Subject: Re: Optimization about count(*) List-Archive: http://lists.mysql.com/internals/38230 Message-Id: <20110109154122.GA16230@janus.mylan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Hi, ??????! On Jan 09, ?????? wrote: > sql: > select count(*) from t where id > 10 and id < 1000000; > In table t, there is an B-tree index on id field, this sql will read > hundreds of thousandes of lines from the storage engine, this is a > time-consuming operation. > If tell the storage engine computing the count in the range, does it > have higher performance? (using records_in_range() api and so on) There's no API for that in MySQL yet. records_in_range() is approximate, it cannot be used for count(*). Regards, Sergei