making query more efficient when there is a millions of row
0
votes
1
answer
90
views
My table consists of the following columns:
job_id,
event_type,
timestamp,
client_type,
role_type,
Every job_id has record of which event_type (example login, edit, delete) , what timestamp, which role did the event (system, master, agent) and which client it happened.
My query is that I want to find the list of job_id that DO NOT have a login event BUT have a DELETE event and acted by the system
I tried a simple query using only one condition (have a loggedin event), but the DB times out/ lost connection. Is there anything I could do?
SELECT
job_id
FROM
table.events
WHERE
wa_id NOT IN (SELECT
wa_id
FROM
table.events
WHERE
event_type = 'LoggedIn'
)
AND role_type = 'MASTER'
AND YEAR(timestamp) = '2023'
AND platform_id = '1';
Asked by orrie881
(1 rep)
Jan 26, 2023, 08:44 AM
Last activity: Jan 26, 2023, 11:29 AM
Last activity: Jan 26, 2023, 11:29 AM