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
1770
November 05, 2015 04:15PM
720
November 05, 2015 05:42PM
772
November 05, 2015 06:54PM
697
November 05, 2015 11:19PM
787
November 06, 2015 11:58AM
710
November 06, 2015 12:35PM
687
November 06, 2015 06:44PM
Re: Foreman query optimization
781
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.