Fwd: Re: Slow subquery on large dataset

From: daq <daq(at)ugyvitelszolgaltato(dot)hu>
To: pgsql-novice(at)postgresql(dot)org
Subject: Fwd: Re: Slow subquery on large dataset
Date: 2004-02-21 12:42:20
Message-ID: 483454830.20040221134220@ugyvitelszolgaltato.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-novice by date

  From Date Subject
Next Message Nabil Sayegh 2004-02-21 14:22:52 easy backup?
Previous Message joseph speigle 2004-02-21 10:26:13 Re: Create Rule