dbTalk Databases Forums  

partial index on a text field

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss partial index on a text field in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Chris
 
Posts: n/a

Default partial index on a text field - 10-24-2004 , 10:14 PM






Hi all,

I have a text field which I'll be doing LIKE searches against so I
wanted to set up an index on it.

The data itself is too long to create a full index, so I can't just:

chris=> create index blah on ff_index(icontent);
ERROR: index row requires 21216 bytes, maximum size is 8191

So I thought I'd set up an index to use the first say 200 chars of the
string

chris=> create index blah on ff_index(substring(icontent, 0, 200));
ERROR: syntax error at or near "(" at character 40

I've tried many variations of this, same result.

I know I can create a partial index on it if the field is less than 200
chars, but that doesn't help me.

I'm running v7.4.5.

Any suggestions ?

Thanks,
Chris.


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: partial index on a text field - 10-24-2004 , 10:56 PM






"Chris" <chris (AT) interspire (DOT) com> writes:
Quote:
chris=> create index blah on ff_index(substring(icontent, 0, 200));
ERROR: syntax error at or near "(" at character 40

I'm running v7.4.5.
Put an extra set of parens around it:

create index blah on ff_index((substring(icontent, 0, 200)));

"substring" looks like a function invocation but it isn't exactly,
so you have to treat this as a general expression index. (This little
inconsistency is fixed for 8.0, btw.)

Note that the index will only do you any good if your queries are
specifically written as "substring(icontent, 0, 200) LIKE 'pattern'".
I suspect that you should instead be looking at full-text-indexing
methods (see contrib/tsearch2, for instance).

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
  #3  
Old   
Chris
 
Posts: n/a

Default Re: partial index on a text field - 10-24-2004 , 11:05 PM



Hi Tom,

Perfect, thanks

I'll have another look at FTI now to see how it works (though from
memory it's a tedious process to get up and running).

Chris.

-----Original Message-----
From: Tom Lane [mailto:tgl (AT) sss (DOT) pgh.pa.us]
Sent: Monday, October 25, 2004 1:57 PM
To: Chris
Cc: pgsql-general (AT) postgresql (DOT) org
Subject: Re: [GENERAL] partial index on a text field


"Chris" <chris (AT) interspire (DOT) com> writes:
Quote:
chris=> create index blah on ff_index(substring(icontent, 0, 200));
ERROR: syntax error at or near "(" at character 40

I'm running v7.4.5.
Put an extra set of parens around it:

create index blah on ff_index((substring(icontent, 0, 200)));

"substring" looks like a function invocation but it isn't exactly, so
you have to treat this as a general expression index. (This little
inconsistency is fixed for 8.0, btw.)

Note that the index will only do you any good if your queries are
specifically written as "substring(icontent, 0, 200) LIKE 'pattern'". I
suspect that you should instead be looking at full-text-indexing methods
(see contrib/tsearch2, for instance).

regards, tom lane


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.