Re: DELETE query and indexes again

From: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: DELETE query and indexes again
Date: 2020-07-23 21:51:17
Message-ID: CAOC+FBX+H_PWi9ZoNeqe2FA1L-QtwVwpWCzqGMizQ9K2TqCACA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

So, uses the index:

explain analyze delete from statcast.play_statistics as ps
using stats as s
where ps.gid = s.gid
and ps.guid = s.guid;

It does this:

-> Index Scan using play_statistics_pkey on play_statistics ps
(cost=0.69..8.59 rows=1 width=26) (actual time=0.008..0.065 rows=108
loops=21063)
Index Cond: ((gid = s.gid) AND (guid = s.guid))

Does not use the index:

explain analyze delete from statcast.play_statistics where gid in (select
distinct gid from stats);

It does this:
-> Seq Scan on play_statistics (cost=0.00..7781818.16 rows=96600516
width=10) (actual time=201.521..396052.101 rows=96556116 loops=1)

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Dischner, Anton 2020-07-24 08:44:32 AW: Encryption in pg_dump
Previous Message Wells Oliver 2020-07-23 21:48:13 Re: DELETE query and indexes again