B> foo=# SELECT data_id FROM capacity_data WHERE data_id NOT IN (SELECT
B> data_id FROM capacities);
Don't use the IN operator if it posible! Too slow.
Select data_id from capacity_data where not exists(select * from capacities where capacity_data.data_id::bigint=capacities.data_id);
Note the "::bigint" cast. If you don't cast capacity_data.data_id to bigint
Postgres will not use the pk index on capacities table. You must cast, or use BIGSERIAL type in capacity_data.
DAQ