logo       
Google Custom Search
    AddThis Social Bookmark Button

Fwd: Re: Slow subquery on large dataset: msg#00167

Subject: Fwd: Re: Slow subquery on large dataset
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


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings




Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>