Re: Advise about how to delete entries - Mailing list pgsql-performance

From PFC
Subject Re: Advise about how to delete entries
Date
Msg-id op.swhh87t5th1vuj@localhost
Whole thread Raw
In response to Advise about how to delete entries  (Arnau <arnaulist@andromeiberica.com>)
Responses Re: Advise about how to delete entries
List pgsql-performance
>     "DELETE FROM statistics_sasme WHERE statistic_id = 9832;"

    As Michael said, why use a NUMERIC when a bigint is faster and better for
your use case, as you only need an integer and not a fixed precision
decimal ?

    Also if you use postgres < 8, the index will not be used if you search on
a type different from the column type. So, if your key is a bigint, you
should do WHERE  statistic_id = 9832::bigint.

    For mass deletes like this, you should use one of the following, which
will be faster :

    DELETE FROM ... WHERE ID IN (list of values)
    Don't put the 30000 values in the same query, but rather do 300 queries
with 100 values in each.

    COPY FROM a file with all the ID's to delete, into a temporary table, and
do a joined delete to your main table (thus, only one query).

    EXPLAIN DELETE is your friend.

pgsql-performance by date:

Previous
From: Patrick Hatcher
Date:
Subject: Poor SQL performance
Next
From: Josh Berkus
Date:
Subject: Re: Massive performance issues