X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 10044D1B4B8 for ; Sun, 7 Dec 2003 00:37:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 92736-05 for ; Sat, 6 Dec 2003 20:36:46 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 1A25AD1B484 for ; Sat, 6 Dec 2003 20:36:43 -0400 (AST) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id CBD5536D4A; Sat, 6 Dec 2003 19:36:40 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1ASmue-0005WV-00; Sat, 06 Dec 2003 19:36:40 -0500 To: "Grace C. Unson" Cc: "PgSQL SQL" Subject: Re: Index not recognized References: <3FD0A87B.4010803@scmbb.ulb.ac.be> <001101c3bbb6$8b0db840$ec64a8c0@GREECE> In-Reply-To: <001101c3bbb6$8b0db840$ec64a8c0@GREECE> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 06 Dec 2003 19:36:40 -0500 Message-ID: <87ptf11n1j.fsf@stark.dyndns.tv> Lines: 42 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/55 X-Sequence-Number: 16221 "Grace C. Unson" writes: > Why is it that my index for text[] data type is not recognized by the > Planner? > > I did these steps: > > 1. create function textarr(text[]) returns text language sql as 'select > $1[1]' strict immutable > 2. create index org_idx on EmpData (textarr(org)); This index will only be used if you use the expression textarr(org) in your query. You would probably have some success if you did: select * from empdata where textarr(org) = 'math' > 3. vacuum full > 4. explain analyze select name from EmpData where org *= 'math'; Is this *= operator from the contrib/array directory? It's not an indexable operator at all using standard btree indexes. The GiST indexing does make indexable operators that can do things like *= but that's a whole other ball of wax. What are you really trying to do? > Result: > ========= > Seq Scan on EmpData (cost=0.00..3193.20 rows=102 width=488) > (actual time=3.71.35..371.35 rows=0 loops=1) > > Filter: (org[0]='math'::text) Well that's awfully odd. I don't know how that expression came out of the query you gave. You'll have to give a lot more information about how you're defining *= and why you think it's related to the function you used to define the index. -- greg