| From: | "Joshua Tolley" <eggyknap(at)gmail(dot)com> | 
|---|---|
| To: | "Bill Thoen" <bthoen(at)gisnet(dot)com> | 
| Cc: | "pgsql-general General" <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: UPDATE and Indexes and Performance | 
| Date: | 2008-10-15 16:57:00 | 
| Message-ID: | e7e0a2570810150957u492ad26t3a586d84735df36e@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
On Wed, Oct 15, 2008 at 10:42 AM, Bill Thoen <bthoen(at)gisnet(dot)com> wrote:
> Does PG (8.1) ever use existing indexes when executing an UPDATE?
>
> I've got some tables with millions of records and whenever I update a column
> that involves most or all the records the EXPLAIN command seems to indicate
> that it isn't using the pre-existing indexes. This result in a slow update,
> which is further slowed by the presence of indexes. So when doing a large
> update should I just drop the indexes first, or is there some good reason to
> keep them?
>
> Thanks,
> - Bill Thoen
You have to hit the disk twice if you use an index -- once to read the
index and once to read the table itself. If the planner guesses that
an operation involves most of the records in a table, it will avoid
indexes and just seqscan, because it's faster.
- Josh / eggyknap
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrus | 2008-10-15 17:04:21 | Re: Opptimizing projections containing unused columns | 
| Previous Message | Bill Thoen | 2008-10-15 16:42:49 | UPDATE and Indexes and Performance |