Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 0050D650170 for ; Mon, 10 Nov 2008 12:19:19 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 17891-08 for ; Mon, 10 Nov 2008 12:19:18 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.191]) by mail.postgresql.org (Postfix) with ESMTP id 2B73F650115 for ; Mon, 10 Nov 2008 12:19:17 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id c7so1450461nfi.23 for ; Mon, 10 Nov 2008 08:19:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=1BCf3iIonL0DQlFt9/xO4I/c2wSpxCNyZRyvxJz1S2A=; b=Zxjnwq5rrh+EO/r7Z1Z5MSGbu7sTzc8zDjy4S4BbYl3ne5nkwRYcNDKiPW6oFuXFbq nmzfMzod7ZxmUWCFyLH5sU93jV9BlQJdLRpQflRWyd+NQmNz+1Ruzgcc8s38MpHFpmyN fP4ClOAn6V3Iod9pQpxzjs0Z7a0yJKYEdyLxg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=kYWvAeZ24uOVt9GkdeO28sF24G8GR7DOIIP97GaL+F3h4hcCsEXTO8HwQFi0CHoJZ8 Us9gJOTGtzpebanBM5V1lnBVp+kvq/8liY5RNLEd+YaFWCucFZ5K+wPuMuOlabIJk52u Ni0KnwKCkEhqf76vvRSVeI5IAMGuTsbZV9hYQ= Received: by 10.86.54.3 with SMTP id c3mr7409753fga.33.1226333955599; Mon, 10 Nov 2008 08:19:15 -0800 (PST) Received: from ?94.27.207.215? (gprs5e1bcfd7.pool.t-umts.hu [94.27.207.215]) by mx.google.com with ESMTPS id 3sm11008051fge.3.2008.11.10.08.19.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 10 Nov 2008 08:19:13 -0800 (PST) Message-ID: <49185EF9.6070009@gmail.com> Date: Mon, 10 Nov 2008 17:19:05 +0100 From: =?ISO-8859-1?Q?Lutisch=E1n_Ferenc?= User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: Vladimir Sitnikov CC: Craig Ringer , pgsql-performance@postgresql.org Subject: Re: Improve Seq scan performance References: <4917D9C3.9060001@gmail.com> <4917DAFB.8000003@postnewspapers.com.au> <1d709ecc0811092337q74fee9e7vc418eba9c798f3a4@mail.gmail.com> In-Reply-To: <1d709ecc0811092337q74fee9e7vc418eba9c798f3a4@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200811/58 X-Sequence-Number: 31789 Dear Vladimir, Thanks for clear description of the problem. :-) Please report it to the bug list. I hope it will be accepted as a "performance bug" and will be solved. Best Regards, Ferenc Vladimir Sitnikov wrotte: > > As far as I understand, it is discouraged to implement/suggest patches > during Commitfest, however, I would love to treat the following case > as a "performance bug" and add it to the "TODO" list: > > > create table seq_test > as select cast(i as text) i, repeat('*', 500) padding from > generate_series(1,10000) as s(i); > > create index i_ix on seq_test(i); > > vacuum analyze verbose seq_test; > -- index "i_ix" now contains 10000 row versions in *30 *pages > -- "seq_test": found 0 removable, 10000 nonremovable row versions in > *667 *pages > > explain analyze select * from seq_test where i like '%123%'; > -- Seq Scan reads 667 pages (as expected) > Seq Scan on seq_test (cost=0.00..792.00 rows=356 width=508) (actual > time=0.129..9.071 rows=20 loops=1 read_shared=*667*(667) > read_local=0(0) flush=0 local_flush=0 file_read=0 file_write=0) > Filter: (i ~~ '%123%'::text) > Total runtime: 9.188 ms > > set enable_seqscan=off > -- Index Scan reads 2529 pages for some reason. I would expect *30 > *(index size) + *20 *(number of matching entries) = 50 pages maximum, > that is 10 times better than with seq scan. > Index Scan using i_ix on seq_test (cost=0.00..1643.74 rows=356 > width=508) (actual time=0.334..16.746 rows=*20 *loops=1 > read_shared=2529(2529) read_local=0(0) flush=0 local_flush=0 > file_read=0 file_write=0) > Filter: (i ~~ '%123%'::text) > Total runtime: 16.863 ms > > Hopefully, there will be a clear distinction between filtering via > index and filtering via table access.