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
1861
November 05, 2015 04:15PM
782
November 05, 2015 05:42PM
802
November 05, 2015 06:54PM
736
November 05, 2015 11:19PM
824
November 06, 2015 11:58AM
746
November 06, 2015 12:35PM
726
November 06, 2015 06:44PM
Re: Foreman query optimization
822
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.