Re: [SQL] How to optimize a query... - Mailing list pgsql-sql

From Ross J. Reedstrom
Subject Re: [SQL] How to optimize a query...
Date
Msg-id 36E56EC4.F9AD68E8@rice.edu
Whole thread Raw
In response to How to optimize a query...  (secret <secret@kearneydev.com>)
List pgsql-sql
secret wrote:
<description of sloq query, with proper EXPLAIN output... thanks!>

Hmm, it looks like your tables are big enough to benefit from indices,
but the query plan didn't choose any. I'd guess an index on po.po_id,
and perhaps tickets.material_po and tickets.trucking_po might help.

From what I understand, indices are of most use on attributes (fields)
that are mostly unique, like your po_id is (probably). They can hurt you
if you build them on fields that are mostly _not_ unique (the classic
example being a gender field - only two likely values, lost of rows
returned for either, so you scan anyway...)

Any real experts out there to correct me? ;-)

Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005

pgsql-sql by date:

Previous
From: Fernezelyi Marton
Date:
Subject: help
Next
From: "Tim Perdue"
Date:
Subject: Performance