473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

partial index on a text field

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

Nov 23 '05 #1
2 5596
"Chris" <ch***@interspire.com> writes:
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 ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #2
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:tg*@sss.pgh.pa.us]
Sent: Monday, October 25, 2004 1:57 PM
To: Chris
Cc: pg***********@postgresql.org
Subject: Re: [GENERAL] partial index on a text field
"Chris" <ch***@interspire.com> writes:
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 ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bruce D | last post by:
I have a table, table1, with the field 'areacodeplustelephone'. This field is of length 10. I created an index called 'areacode' that only uses the first three characters. Can I use this index...
0
by: Robert Oschler | last post by:
I read a while back that MySQL will only use one index per query. (If this is not so, please tell me and point me to a doc that gives a good explanation of MySQL's current index usage policy). ...
1
by: Robert Oschler | last post by:
I read a while back that MySQL will only use one index per query. (If this is not so, please tell me and point me to a doc that gives a good explanation of MySQL's current index usage policy). ...
10
by: ptass | last post by:
Hi In asp.net 2.0 an aspx files .cs file is a partial class and all works fine, however, I thought I’d be able to create another class file, call it a partial class and have that compile and...
1
by: Unregistered | last post by:
I have following situation: one "message" table and 3 other "message_{1,2,3}" tables which inheri from "message". Every day +-50 000 "messages" are being inserted. I needed something extra to...
1
by: Liu, Mingyi | last post by:
Sorry if this question has been asked before. I tried to search in postgres mailing lists at http://archives.postgresql.org/pgsql-general/ just now and it gave me error "An error occured! Can not...
2
by: Stephen | last post by:
Hi, Suppose there is a column in the dataset that is a very large field (say varchar(500)) and i want to display partial information with (....) so that the user can click on it to view for...
15
RMWChaos
by: RMWChaos | last post by:
As usual, an overly-long, overly-explanatory post. Better too much info than too little, right? A couple weeks ago, I asked for some assistance iterating through a JSON property list so that my...
4
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.