X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 2664D9DCDEC for ; Sat, 4 Mar 2006 17:27:39 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52955-10 for ; Sat, 4 Mar 2006 17:27:39 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.194]) by postgresql.org (Postfix) with ESMTP id 716549DCD89 for ; Sat, 4 Mar 2006 17:27:36 -0400 (AST) Received: by wproxy.gmail.com with SMTP id i13so1140490wra for ; Sat, 04 Mar 2006 13:27:38 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:to:subject:date:user-agent:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; b=s7PdEW2RzIV2iaqyUnncr2NB9lDYsZYGZpJA5QSNp+agzPN7GJgkIEB00bQ0dFHkiUarLJ1445SkXyH2XJ4xZbXvYG4iw7Aqp0F0Zc7ap1dwhEBasurEwPCU22voe7I/9+W7jsdPfZOWHOf21qgCXhXlQmMU5TtmuFP9hN4xzWU= Received: by 10.54.135.19 with SMTP id i19mr487274wrd; Sat, 04 Mar 2006 13:27:38 -0800 (PST) Received: from ?10.0.2.2? ( [200.62.104.176]) by mx.gmail.com with ESMTP id g3sm3636038wra.2006.03.04.13.27.37; Sat, 04 Mar 2006 13:27:38 -0800 (PST) From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: How to query and index for customer with lastname and city Date: Sat, 4 Mar 2006 15:35:17 -0600 User-Agent: KMail/1.8.3 References: <1141466283.6729.17.camel@localhost> <1141481903.10078.14.camel@localhost> <9e4684ce0603040623p24f4672bk55a0a303152138aa@mail.gmail.com> In-Reply-To: <9e4684ce0603040623p24f4672bk55a0a303152138aa@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200603041535.17882.blargity@gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200603/28 X-Sequence-Number: 17465 On Saturday 04 March 2006 08:23, hubert depesz lubaczewski wrote: > On 3/4/06, Joost Kraaijeveld wrote: > > > how many record do you have in the customers table? > > > > 368915 of which 222465 actually meet the condition. > > > > >From what I understand from the mailing list, PostgreSQL prefers a table > > > > scan whenever it expects that the number of records in the resultset > > will be ~ > 10 % of the total number of records in the table. Which > > explains the table scan for customers, but than again, it does not > > explain why it uses the index on addresses: it has 369337 addresses of > > which 158003 meet the condition > > bitmap index scan is faster than sequential table scan. that's all. it > was introduced in 8.1 as far as i remember. > basically - i doubt if you can get better performace from query when > the result row-count is that high. > > out of curiosity though - why do you need so many rows? it's not > possible to view them, nor do anything meaningful with 200 thousand > rows! > > depesz If you're just displaying, use limit and offset to grab one page at a time. If you're manipulating it would be a good idea to do something in a stored procedure.