Re: Delete performance - Mailing list pgsql-novice

From Jana
Subject Re: Delete performance
Date
Msg-id op.uvkimjhng6o41l@truhlik
Whole thread Raw
In response to Delete performance  (Jana <jana.vasseru@gmail.com>)
Responses Re: Delete performance
List pgsql-novice
On Sun, 14 Jun 2009 18:12:50 +0200, Frank Bax <fbax@sympatico.ca> wrote:

> Jana wrote:
>>  Hello,
>> i have a table with about 250m records from which i want to delete
>> thoose not contained in other table. I used this SQL query:
>> DELETE FROM data_structures_items WHERE id_data_structure NOT IN (
>> SELECT id_structure FROM data_structures);
>
>
> DELETE FROM data_structures_items, data_structures WHERE
> data_structures_items.id_data_structure =
> data_structures.id_data_structure AND
> data_structures_items.id_data_structure IS NULL;
>

Thanks for answer, this however is not a valid syntax (at least according
to manual, and my 8.3)
version. What could be done is

DELETE FROM data_structures_items USING data_structures
WHERE
data_structures_items.id_data_structure=data_structures.id_structure
AND something

but the problem is in that "something". I cannot write
data_structures_items.id_data_structure =
data_structures.id_data_structure AND
data_structures_items.id_data_structure IS NULL;

because it a) doesn't make sense (column can't be null and equal to
something at the same time), b) doesn't select what i want (rows whoose
id_data_structure is NOT in the data_structures table, i'm pretty sure it
is a number ). I can't join tables in DELETE command, and i can't think of
a way doing it with WHERE

Regards,
  Jana

pgsql-novice by date:

Previous
From: Frank Bax
Date:
Subject: Re: Delete performance
Next
From: Phillip Sitbon
Date:
Subject: Re: Delete performance