From: Dave Dutcher <dave@tridecap.com>
To: 'Dan Harris' <fbsd@drivefaster.net>
To: 'PostgreSQL Performance' <pgsql-performance@postgresql.org>
Subject: Re: Planner doing seqscan before indexed join
Date: Thu, 29 Mar 2007 19:15:23 -0500
Message-ID: <019201c77260$82f91fa0$2e00a8c0@tridecap.com> (raw)
In-Reply-To: <460B22E1.7070904@drivefaster.net>
> From: pgsql-performance-owner@postgresql.org
> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of
> Dan Harris
>
> After some digging, I've found that the planner is choosing
> to apply a necessary seq scan to the table. Unfortunately,
> it's scanning the whole table, when it seems that it could
> have joined it to a smaller table first and reduce the
> amount of rows it would have to scan dramatically ( 70
> million to about 5,000 ).
>
Joining will reduce the amount of rows to scan for the filter, but
performing the join is non-trivial. If postgres is going to join two tables
together without applying any filter first then it will have to do a seqscan
of one of the tables, and if it chooses the table with 5000 rows, then it
will have to do 5000 index scans on a table with 70 million records. I
don't know which way would be faster.
I wonder if you could find a way to use an index to do the text filter.
Maybe tsearch2? I haven't used anything like that myself, maybe someone
else has more input.
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: dave@tridecap.com, fbsd@drivefaster.net
Subject: Re: Planner doing seqscan before indexed join
In-Reply-To: <019201c77260$82f91fa0$2e00a8c0@tridecap.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