From: Tom Lane <tgl@sss.pgh.pa.us>
To: n.howden@eris.qinetiq.com
Cc: pgsql-admin@postgresql.org
Subject: Re: Is is possible to persuade the query planner that ~* operations are grossly expensive?
Date: Tue, 17 Dec 2002 09:23:36 -0500
Message-ID: <6534.1040135016@sss.pgh.pa.us> (raw)
In-Reply-To: <20021217092705.9AC8F476281@postgresql.org>
References: <20021217092705.9AC8F476281@postgresql.org>
Nick Howden <n.howden@eris.qinetiq.com> writes:
> Is is possible to persuade the query planner that ~* operations are grossly
> expensive - or at least much more expensive than some other operations.
I think you're trying to micro-optimize in the wrong place.
> My reason is that I have a databsase on which we do a lot of queries of the
> form
> SELECT
> *
> FROM
> primary_table
> secondary_table as t1
> secondary_table as t2
> WHERE primary_table.id = t1.id
> AND primary_table.id = t2.id
> AND t1.col1 = 1
> AND t2.col1 = 2
> AND primary_table.blob ~* 'wibble';
I get perfectly reasonable-looking plans for a comparable query
structure in the regression database:
regression=# explain select * from tenk1 a, tenk1 b where
regression-# a.unique1 = b.unique1 and b.unique2 = 42
regression-# and a.stringu1 like '%z%';
QUERY PLAN
-------------------------------------------------------------------------------------
Nested Loop (cost=0.00..9.04 rows=1 width=488)
-> Index Scan using tenk1_unique2 on tenk1 b (cost=0.00..3.01 rows=1 width=244)
Index Cond: (unique2 = 42)
-> Index Scan using tenk1_unique1 on tenk1 a (cost=0.00..6.01 rows=1 width=244)
Index Cond: (a.unique1 = "outer".unique1)
Filter: (stringu1 ~~ '%z%'::text)
(6 rows)
I don't see much to improve on there in terms of reducing the number of
executions of the LIKE operator.
How about you show us your schema (column types, index definitions) and
your EXPLAIN ANALYZE output, rather than jumping to conclusions about
the form of a solution to your problem?
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, n.howden@eris.qinetiq.com
Subject: Re: Is is possible to persuade the query planner that ~* operations are grossly expensive?
In-Reply-To: <6534.1040135016@sss.pgh.pa.us>
References: <20021217092705.9AC8F476281@postgresql.org> <6534.1040135016@sss.pgh.pa.us>
* 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