From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruce De Vries <bpd@bpdconsulting.com>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Search parameter optimization
Date: Thu, 21 Oct 1999 15:47:47 -0400
Message-ID: <17911.940535267@sss.pgh.pa.us> (raw)
In-Reply-To: <4.2.1.9.19991021091614.05cf3820@pacbell.net>
Bruce De Vries <bpd@bpdconsulting.com> writes:
> I am using postgres to search databases with 1.75 million records. It's a
> yellow pages database. I read through the mailing lists and learned how to
> use the lower function to speed case insensitive searches, but am still
> getting some results that don't make sence. For example:
> select * from ca where lower(company) like 'baskin robbins' and lower(city)
> ~* '^anaheim';
> executes 10 times faster than
> select * from ca where lower(company) like 'baskin robbins' and lower(city)
> like '^anaheim';
(I assume you didn't actually mean LIKE '^anaheim' there? ^ is a plain
data character to LIKE, not a pattern anchor.)
You certainly couldn't get a 10x speed differential just from the
runtime of the matching operators. That has to be due to one query
using a much more efficient query plan than the other. Rather than
speculating about what the system is doing, how about you run an
"explain" on each of these queries and show us the results?
BTW, I trust you have indexes on lower(company) and lower(city)...
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-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, bpd@bpdconsulting.com
Subject: Re: [SQL] Search parameter optimization
In-Reply-To: <17911.940535267@sss.pgh.pa.us>
References: <4.2.1.9.19991021091614.05cf3820@pacbell.net> <17911.940535267@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