pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce De Vries <bpd@bpdconsulting.com>
To: pgsql-sql@postgresql.org
Subject: Search parameter optimization
Date: Thu, 21 Oct 1999 10:42:00 -0700
Message-ID: <4.2.1.9.19991021091614.05cf3820@pacbell.net> (raw)

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';

even though

select * from ca where lower(city) like 'anaheim';

is faster than

select * from ca where lower(city) ~* '^anaheim';

I have issued a "vacuum analyze ca" command.

How to I get the fastest search results from complex expressions?

Is varchar or text better or is char better even though it takes up more 
space?  When searching a 5 digit zip code is char or int better?






-----
Bruce  De Vries, Proprietor          http://www.bpdconsulting.com
B. P. D. Consulting                  (714) 632-3841 Phone
2034 E. Lincoln Ave. PMB #344        (800) 828-9578 Toll Free
Anaheim, CA   92806                  (603) 452-8504 FAX





view thread (2+ messages)  latest in thread

Message-ID: <4.2.1.9.19991021091614.05cf3820@pacbell.net>
Permalink:  ../4.2.1.9.19991021091614.05cf3820@pacbell.net/
Also on:    postgresql.org/message-id/4.2.1.9.19991021091614.05cf3820@pacbell.net

 · 

reply

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: bpd@bpdconsulting.com
  Subject: Re: Search parameter optimization
  In-Reply-To: <4.2.1.9.19991021091614.05cf3820@pacbell.net>
  References: <4.2.1.9.19991021091614.05cf3820@pacbell.net>

* 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