Re: slow DELETE queries - Mailing list pgsql-sql

From Manfred Koizar
Subject Re: slow DELETE queries
Date
Msg-id 0gp3huoagdqn6hs4di0f41r1pi79rttlkj@4ax.com
Whole thread Raw
In response to slow DELETE queries  (Denis <denis@startsiden.no>)
Responses Re: slow DELETE queries  (Denis <denis@startsiden.no>)
List pgsql-sql
On Thu, 20 Jun 2002 15:23:53 +0200, Denis <denis@startsiden.no> wrote:
>I traced the queries slowing it all down to this snippet in the debug log:
>DELETE FROM phpbb_search_wordlist WHERE word_id IN (
>SELECT word_id FROM phpbb_search_wordmatch WHERE word_id IN (
>SELECT word_id FROM phpbb_search_wordmatch WHERE post_id IN (70535) 
>GROUP BY word_id) GROUP BY word_id HAVING COUNT(word_id) = 1)

Denis,

IN is known to be problematic;  try to use EXISTS or =, wherever
possible.  Can you rewrite your innermost where clause to WHERE
post_id = 70535?

Also create an index on phpbb_search_wordmatch.post_id.

If it's still too slow, give us some more information:
Is word_id unique in phpbb_search_wordlist?
Is (post_id, word_id) unique in phpbb_search_wordmatch?
How many rows are in your tables?

ServusManfred


pgsql-sql by date:

Previous
From: Arve Fahlvik
Date:
Subject: Re: Assign values to array
Next
From: Bruce Momjian
Date:
Subject: Re: Which one is faster?