Hi all,
I have a DTS package pulling data from TotalView's IEX database. While I haven't been able to get a straight answer on the type of database IEX uses, I can tell you that my DSN uses the Simba Client driver.
I am having a problem querying records by date. Specifically, I am pulling records that are greater than or equal to yesterday's date. Here is my query:
Now, the query does return the records that I need, however it has some of the worst performance I've ever seen. For example, to pull 19,601 records matching that criteria, the query today ran for one hour and six minutes! This represents typical performance. However, if I pull the entire table, regardless of date, I can get it loaded in about the same amount of time.
I have tried using the following:
and other date functions, but I always receive an "Invalid scalar function" error.
So what gives? How can I optimize this query?
I have a DTS package pulling data from TotalView's IEX database. While I haven't been able to get a straight answer on the type of database IEX uses, I can tell you that my DSN uses the Simba Client driver.
I am having a problem querying records by date. Specifically, I am pulling records that are greater than or equal to yesterday's date. Here is my query:
Code:
SELECT
CUSTOMER_ID, CT_ID, BEGIN_PERIOD, END_PERIOD,
FIRST_DATE_TIME, MODIFY_DATE_TIME, DATE_TIME,
IN_TIME, OUT_TIME, INTERNAL_TIME, READY_TIME,
ACW_TIME, IDLE_TIME, LOGIN_TIME, BACKLOG_NOT_EXPIRED,
BACKLOG_EXPIRED, RIG_FCST_CTS_HNDL, REV_FCST_CTS_HNDL,
ORIG_ACT_CONTACTS_HNDL, REV_ACT_CONTACTS_HNDL,
ORIG_REQ_MAX_OCC, REV_REQ_MAX_OCC, ACT_STAFF,
MAX_OCC, ORIG_ABAND_CONTACTS, REV_ABAND_CONTACTS,
ABAND_BEFORE_SL, HANDLED_BEFORE_SL, OUT_CONTACTS,
INTERNAL_CONTACTS, ORIG_FCST_CONTACTS_RCVD,
ORIG_FCST_AHT, REV_FCST_CONTACTS_RCVD, REV_FCST_AHT,
ORIG_SL_PCT, ORIG_SL_SECS, ORIG_ACT_CONTACTS_RCVD,
ORIG_AHT, OCCUPANCY, SERVICE_LEVEL,
REV_ACT_CONTACTS_RCVD, REV_AHT, ORIG_ACTUAL_ASA,
REV_ACTUAL_ASA, ASA_GOAL, ORIG_REQ_ASA, REV_REQ_ASA,
ORIG_REQ_SL, REV_REQ_SL, BU_EFFICIENCY_FROM_SL,
BU_EFFICIENCY_FROM_ASA, ALL_QS_REPORTED, REQ_CALC_TYPE
FROM
"."."result"
WHERE
DATE_TIME >= (CURDATE()-1)
Now, the query does return the records that I need, however it has some of the worst performance I've ever seen. For example, to pull 19,601 records matching that criteria, the query today ran for one hour and six minutes! This represents typical performance. However, if I pull the entire table, regardless of date, I can get it loaded in about the same amount of time.
I have tried using the following:
Code:
WHERE DATE_TIME >= DATE_ADD(d, -1, GETDATE())
and other date functions, but I always receive an "Invalid scalar function" error.
So what gives? How can I optimize this query?