MySQL Forums
Forum List  »  Performance

Re: Foreman query optimization
Posted by: Rick James
Date: November 26, 2015 08:56PM

`logs` is a lot larger than `sources`, so there must be a lot of duplicate `source_id` values, correct? So, let's dedup to make things smaller and hopefully faster:

CREATE TEMPORARY TABLE t (
    PRIMARY KEY (source_id)
)
SELECT DISTINCT source_id FROM logs;

DELETE
    FROM from sources as s
    left join t on s.id = t.source_id
    where t.source_id is NULL;

Options: ReplyQuote


Subject
Views
Written By
Posted
2033
November 05, 2015 04:15PM
878
November 05, 2015 05:42PM
899
November 05, 2015 06:54PM
827
November 05, 2015 11:19PM
941
November 06, 2015 11:58AM
840
November 06, 2015 12:35PM
816
November 06, 2015 06:44PM
Re: Foreman query optimization
921
November 26, 2015 08:56PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.