Fixing full-text search
After focusing on some highly important and common problems related to indexing, it is time to discuss the most important pitfalls in the area of full-text indexing.
Not using full-text search at all
One of the most common mistakes made is not to use full-text search at all. Many people tend to use LIKE
instead of proper, PostgreSQL-style full-text searching. Doing that can open a Pandora's box and result in various performance issues.
To demonstrate the point, some sample text can be loaded. In this case, Shakespeare's Hamlet has been selected, which can be downloaded freely from www.gutenberg.org (an archive of free books). To load the data, end users can turn to curl
, just as was shown before in the previous example. PostgreSQL will read the data from the pipe:
test=# CREATE TABLE t_text (payload text); CREATE TABLE test=# COPY t_text FROM PROGRAM 'curl http://www.gutenberg.org/cache/epub/2265/pg2265.txt'; COPY 5302
In this example, 5302 lines of text have been loaded...