Fwd: Re: Slow subquery on large dataset - Mailing list pgsql-novice

From daq
Subject Fwd: Re: Slow subquery on large dataset
Date
Msg-id 483454830.20040221134220@ugyvitelszolgaltato.hu
Whole thread Raw
List pgsql-novice
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


pgsql-novice by date:

Previous
From: joseph speigle
Date:
Subject: Re: Create Rule
Next
From: Nabil Sayegh
Date:
Subject: easy backup?