I have a table that houses all of the logs of the system. It houses the insertion and update logs of an item. My query checks the latest updates based on the last time the system checked for updates.
Here is my query:
SELECT LCINDIV.CLIENTID, LCINDIV.COID, BIRTHDAY, NATIONAL, ACRNO, CIVSTAT, GENDER, RELIGION, SSSID, TIN, RESCERT, EDUCLV, DEGREE, RESIDENT, LNAME, FNAME, MNAME, DTPLRES, NATIONLT, LCINDIV.SERVERUPDATE
FROM LCINDIV
LEFT OUTER JOIN LCCLIENT
ON LCCLIENT.CLIENTID = LCINDIV.CLIENTID
WHERE
AUDITKY IN (SELECT AUDITKY FROM LSAUDIT WHERE ENTRYDT > '04-Nov-2019' AND ENTRYTM > '15:15:10')
Here is what my query does it will get the client information if the AUDITKY is in the AUDITKY of the table LSAUDIT WHERE the ENTRYDT is greater than the current date and ENTRYTM is greater than the current time.
My problem is when I execute this query it takes about 30-60 seconds to execute. Is there a way for me to improve my SQL Query?
Table Specs:
LCCLIENT - 5,000+ rows
LCINDIV - 5,000+ rows
LSUDIT - 5,000,000+ rows
Table Structure:
LSAUDIT Table
AUDITNO CHAR
AUDITTP CHAR
AUDITKY CHAR
ENTRYBY CHAR
ENTRYDT DATE
ENTRYTM CHAR