Re: Help speeding up delete

From: Steve Wampler <swampler(at)noao(dot)edu>
To: Scott Lamb <slamb(at)slamb(dot)org>
Cc: Postgres-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Help speeding up delete
Date: 2005-11-15 04:03:56
Message-ID: 43795E2C.4040502@noao.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance pgsql-www

Scott Lamb wrote:
> On Nov 14, 2005, at 3:52 PM, Steve Wampler wrote:
>
>> Scott Lamb wrote:
>>
>>> On Nov 14, 2005, at 2:07 PM, Steve Wampler wrote:
>>>
>>>> # SELECT at.id FROM "tmp_table2" at, "tmp_tabl2e" a
>>>> # WHERE at.id=a.id and a.name='obsid' and a.value='oid080505';
>>>
>>>
>>>
>>> Isn't this equivalent?
>>>
>>> select id from tmp_table2 where name = 'obsid' and value = 'oid080505';
>>
>>
>> Probably, the user based the above on a query designed to find
>> all rows with the same id as those rows that have a.name='obsid' and
>> a.value='oid080505'.
>
>
> Well, this indirection is only significant if those two sets can
> differ. If (A) you meant "tmp_table2" when you wrote "tmp_tabl2e", so
> this is a self-join, and (B) there is a primary key on "id", I don't
> think that can ever happen.

I wasn't clear. The original query was:

SELECT at.* FROM "tmp_table2" at, "tmp_table2" a
WHERE at.id=a.id and a.name='obsid' and a.value='oid080505';

which is significantly different than:

SELECT * FROM "tmp_table2" WHERE name='obsid' and value='oid080505';

The user had adapted that query for her needs, but it would have been
better to just use the query that you suggested (as the subselect in
the DELETE FROM...). Unfortunately, that only improves performance
slightly - it is still way too slow on deletes.

--
Steve Wampler -- swampler(at)noao(dot)edu
The gods that smiled on your birth are now laughing out loud.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Claus Guttesen 2005-11-15 08:28:30 Re: Hardware/OS recommendations for large databases (5TB)
Previous Message Leigh Dyer 2005-11-15 01:18:48 Re: Help speeding up delete

Browse pgsql-www by date

  From Date Subject
Next Message Bruce Momjian 2005-11-15 05:13:01 Re: 8.1 PDF Documentation.
Previous Message Bruce Momjian 2005-11-15 02:46:06 GUI guide