X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id ED693D1C9E1 for ; Thu, 31 Jul 2003 19:45:17 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 73129-08 for ; Thu, 31 Jul 2003 16:44:13 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id E48A5D1C9DE for ; Thu, 31 Jul 2003 16:45:15 -0300 (ADT) 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 h6VJivQ3018306; Thu, 31 Jul 2003 15:44:57 -0400 (EDT) To: Scott Cain Cc: pgsql-performance@postgresql.org Subject: Re: EXTERNAL storage and substring on long strings In-reply-to: <1059679600.1429.41.camel@localhost.localdomain> References: <1059679600.1429.41.camel@localhost.localdomain> Comments: In-reply-to Scott Cain message dated "31 Jul 2003 15:26:40 -0400" Date: Thu, 31 Jul 2003 15:44:57 -0400 Message-ID: <18305.1059680697@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/511 X-Sequence-Number: 2804 Scott Cain writes: > explain analyze select substring(residues from 1000000 for 20000) > from feature where feature_id=1; > where feature is a table with ~3 million rows, and residues is a text > column, where for the majority of the rows of feature, it is null, for a > large minority, it is shortish strings (a few thousand characters), and > for 6 rows, residues contains very long strings (~20 million characters > (it's chromosome DNA sequence from fruit flies)). I think the reason uncompressed storage loses here is that the runtime is dominated by the shortish strings, and you have to do more I/O to get at those if they're uncompressed, negating any advantage from not having to fetch all of the longish strings. Or it could be that there's a bug preventing John Gray's substring-slice optimization from getting used. The only good way to tell that I can think of is to rebuild PG with profiling enabled and try to profile the execution both ways. Are you up for that? (BTW, if you are using a multibyte database encoding, then that's your problem right there --- the optimization is practically useless unless character and byte indexes are the same.) regards, tom lane