pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedquest:optimization with indexes
7+ messages / 4 participants
[nested] [flat]
* quest:optimization with indexes
@ 1999-08-10 22:42 Clayton Cottingham <drfrog@smartt.com>
0 siblings, 1 reply; 7+ messages in thread
From: Clayton Cottingham @ 1999-08-10 22:42 UTC (permalink / raw)
To: pgsql-sql
hello,
im looking for info/help on creating indexes
im using 6.5
we have a table overe 100,000 rows
if we put in an index or not an explain say it still does a seq scan,
same amount of time taken!
ive tried putting the index using just the oid , a combo of some fields
of our data using btree
where/what rules should be followed for setting up a good indexing
scheme under pg?
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] quest:optimization with indexes
@ 1999-08-11 13:30 Herouth Maoz <herouth@oumail.openu.ac.il>
parent: Clayton Cottingham <drfrog@smartt.com>
0 siblings, 1 reply; 7+ messages in thread
From: Herouth Maoz @ 1999-08-11 13:30 UTC (permalink / raw)
To: Clayton Cottingham <drfrog@smartt.com>; pgsql-sql
At 01:42 +0300 on 11/08/1999, Clayton Cottingham wrote:
> if we put in an index or not an explain say it still does a seq scan,
> same amount of time taken!
>
> ive tried putting the index using just the oid , a combo of some fields
> of our data using btree
>
> where/what rules should be followed for setting up a good indexing
> scheme under pg?
You should put indices on the fields mentioned in your query's WHERE clause.
You should try and avoid using functions on the fields in a WHERE clause.
For example, even if you have an index on the field "surname" in your
table, a query with WHERE upper( surname ) = "SMITH" will not use that
index. You can define indices on the function upper(surname) if this sort
of query is common.
The same goes for operators such as LIKE. LIKE will only use the index if
the expression is anchored to the beginning of the string, as in WHERE
surname LIKE 'Smi%', but not WHERE surname LIKE '%mit%'.
And always keep in mind that adding indices penalizes you on insert and update.
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] quest:optimization with indexes
@ 1999-08-11 14:12 Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
parent: Herouth Maoz <herouth@oumail.openu.ac.il>
0 siblings, 1 reply; 7+ messages in thread
From: Ross J. Reedstrom @ 1999-08-11 14:12 UTC (permalink / raw)
To: pgsql-sql; +Cc: Clayton Cottingham <drfrog@smartt.com>
On Wed, Aug 11, 1999 at 04:30:13PM +0300, Herouth Maoz wrote:
> At 01:42 +0300 on 11/08/1999, Clayton Cottingham wrote:
> >
> > where/what rules should be followed for setting up a good indexing
> > scheme under pg?
>
<snipped Herouth's good summation of the rules of indices>
One thing to add: after adding your index, vacuum analyze you table, or else
the optimizer may thing you've only got a few rows in your table, and refuse
to use the indices, because it thinks sequential scans are relatively cheap.
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
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] quest:optimization with indexes
@ 1999-08-11 17:43 Clayton Cottingham <drfrog@smartt.com>
parent: Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
0 siblings, 1 reply; 7+ messages in thread
From: Clayton Cottingham @ 1999-08-11 17:43 UTC (permalink / raw)
To: ; +Cc: pgsql-sql
thanks all, i actually was able to piece this all together last night!
what i did was create another column that had a nextval sequence
and im using that as an index, instead of over a thousand sec i am now getting
a index with 2 sec
thanks for all those 'like' tips i was wonderinng, would using regex be the
same as far as the indexing rules go?
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] quest:optimization with indexes
@ 1999-08-11 22:35 Tom Lane <tgl@sss.pgh.pa.us>
parent: Clayton Cottingham <drfrog@smartt.com>
0 siblings, 1 reply; 7+ messages in thread
From: Tom Lane @ 1999-08-11 22:35 UTC (permalink / raw)
To: Clayton Cottingham <drfrog@smartt.com>; +Cc: pgsql-sql
Clayton Cottingham <drfrog@smartt.com> writes:
> thanks for all those 'like' tips i was wonderinng, would using regex be the
> same as far as the indexing rules go?
It's equivalent --- an index can help if the pattern is anchored to the
start of the string. Of course the pattern notation is different...
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] quest:optimization with indexes
@ 1999-08-11 23:38 Clayton Cottingham <drfrog@smartt.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 7+ messages in thread
From: Clayton Cottingham @ 1999-08-11 23:38 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
Tom Lane wrote:
> Clayton Cottingham <drfrog@smartt.com> writes:
> > thanks for all those 'like' tips i was wonderinng, would using regex be the
> > same as far as the indexing rules go?
>
> It's equivalent --- an index can help if the pattern is anchored to the
> start of the string. Of course the pattern notation is different...
>
> regards, tom lane
what about helper software like glimpse, as per my other thread?
i was told to use glimpse, because full text index {fti} isnt robust enough to
handle large db's
what do you think the most optimized way of handling this sort of thing would
be?
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [SQL] quest:optimization with indexes
@ 1999-08-12 14:34 Tom Lane <tgl@sss.pgh.pa.us>
parent: Clayton Cottingham <drfrog@smartt.com>
0 siblings, 0 replies; 7+ messages in thread
From: Tom Lane @ 1999-08-12 14:34 UTC (permalink / raw)
To: Clayton Cottingham <drfrog@smartt.com>; +Cc: pgsql-sql
Clayton Cottingham <drfrog@smartt.com> writes:
> what about helper software like glimpse, as per my other thread?
> i was told to use glimpse, because full text index {fti} isnt robust
> enough to handle large db's
AFAIK there isn't any real good way to use glimpse in combination with
Postgres. Glimpse is a file-granularity indexer --- that is, if you are
searching for a word, say "foobar", then glimpse's index tells it which
files within a large directory tree contain that word, and then it goes
and runs "grep foobar" on each such file to find the actual occurrences
of that word. Glimpse works great for large, slowly changing
collections of files (I say "slowly changing" because updating the index
is fairly expensive). For instance, I use it all the time to search the
Postgres source files. But it'd be quite useless for a Postgres
database where all the data is in one table (= one file). Also, there's
no natural equivalent of file granularity in a database; if you did
adapt glimpse to know about the inner structure of a Postgres database,
you'd end up indexing at the record level, which'd be a mighty
inefficient way to use glimpse.
If you do have a moderately large collection of slowly-changing
documents, I'd suggest storing them as a plain tree of files, and using
glimpse and Postgres separately as index-maintaining tools. (That is,
your database would just contain references to the files, plus whatever
information you wanted to manipulate with SQL operations.)
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~1999-08-12 14:34 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-08-10 22:42 quest:optimization with indexes Clayton Cottingham <drfrog@smartt.com>
1999-08-11 13:30 ` Herouth Maoz <herouth@oumail.openu.ac.il>
1999-08-11 14:12 ` Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
1999-08-11 17:43 ` Clayton Cottingham <drfrog@smartt.com>
1999-08-11 22:35 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-08-11 23:38 ` Clayton Cottingham <drfrog@smartt.com>
1999-08-12 14:34 ` Tom Lane <tgl@sss.pgh.pa.us>
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