From: Howard Cole <howardnews@selestial.com>
To: pgsql-performance@postgresql.org
Subject: Re: Tsearch2 Initial Search Speed
Date: Wed, 18 Jun 2008 11:40:11 +0100
Message-ID: <4858E60B.5070300@selestial.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0806171407250.3987@aragorn.flymine.org>
References: <4856A91F.1020001@selestial.com>
<200806161124.57543@hal.medialogik.com>
<485789C1.3000803@selestial.com>
<485797D4.7010201@selestial.com>
<Pine.LNX.4.64.0806171202130.3987@aragorn.flymine.org>
<48579EB1.8050403@selestial.com>
<Pine.LNX.4.64.0806171228480.3987@aragorn.flymine.org>
<4857A739.5020800@selestial.com>
<Pine.LNX.4.64.0806171407250.3987@aragorn.flymine.org>
>
> Actually, the index returns page numbers in the table on disc which
> may contain one or more rows that are relevant. Postgres has to fetch
> the whole row to find out the email_id and any other information,
> including whether the row is visible in your current transaction
> (concurrency control complicates it all). Just having a page number
> isn't much use to you!
>
> Matthew
>
Out of interest, if I could create a multicolumn index with both the
primary key and the fts key (I don't think I can create a multi-column
index using GIST with both the email_id and the fts field), would this
reduce access to the table due to the primary key being part of the index?
More importantly, are there other ways that I can improve performance on
this? I am guessing that a lot of the problem is that the email table is
so big. If I cut out some of the text fields that are not needed in the
search and put them in another table, presumably the size of the table
will be reduced to a point where it will reduce the number of disk hits
and speed the query up.
So I could split the table into two parts:
create table email_part2 (
email_id int8 references email_part1 (email_id),
fts ...,
email_directory_id ...,
)
create table email_part1(
email_id serial8 primary key,
cc text,
bcc text,
...
)
and the query will be
select email_id from email_part2 where to_tsquery('default', 'howard')
@@ fts;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: howardnews@selestial.com
Subject: Re: Tsearch2 Initial Search Speed
In-Reply-To: <4858E60B.5070300@selestial.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox