Hello all,
I'm new to the forum and had some questions about a query I'm trying to speed up.
Here's the environment, Oracle db (version 9) and I'm querying 4 tables. The tables and sizes are:
Table row count
QUESTION 193,336
survey_custom 3,600,279
survey_results 136,993,573
user_survey 4,208,759
The query is:
All of the fields that are joined are indexed. The IN qualifier on the surveyname field is also indexed. The only field that's not indexed in the conditions is the ques_ver_content IN portion.
I did an explain plan on the query and it shows that my cost is: 147,608.
Most of the cost is coming from a nested loop with survey_results and the question_PK_IDX.
I have tried some sub queries to see if I can speed up the query, but the cost increased on every attempt I made.
Any assistance would be great!
Thank you!
I'm new to the forum and had some questions about a query I'm trying to speed up.
Here's the environment, Oracle db (version 9) and I'm querying 4 tables. The tables and sizes are:
Table row count
QUESTION 193,336
survey_custom 3,600,279
survey_results 136,993,573
user_survey 4,208,759
The query is:
Code:
SELECT
trim(QUESTION.QUES_VER_CONTENT),
SURVEY_RESULTS.ANSWERTEXT,
SURVEY_CUSTOM.LOCATION,
SURVEY_CUSTOM.COURSESTARTDATE,
SURVEY_CUSTOM.InstructorID,
SURVEY_CUSTOM.STUDENTID,
SURVEY_CUSTOM.LOCATIONID,
SURVEY_CUSTOM.COURNUM
FROM
QUESTION,
SURVEY_RESULTS,
SURVEY_CUSTOM,
USER_SURVEY
WHERE
( USER_SURVEY.PK_USERSURVEYID=SURVEY_RESULTS.FK_USERSURVEYID )
AND ( SURVEY_RESULTS.FK_QUESTIONVERSIONID=QUESTION.PK_QUESTIONVERSIONID )
AND ( USER_SURVEY.PK_USERSURVEYID=SURVEY_CUSTOM.USERSURVEYID )
AND ( USER_SURVEY.SURVEYNAME) IN ('Survey_1', 'Survey_2','Survey_3')
AND trim(QUESTION.QUES_VER_CONTENT) IN
('Would you like to be contacted?', 'Are you happy with the service?')
AND asap_user_survey.completedate > trunc(ADD_MONTHS(LAST_DAY(SYSDATE), -15))
All of the fields that are joined are indexed. The IN qualifier on the surveyname field is also indexed. The only field that's not indexed in the conditions is the ques_ver_content IN portion.
I did an explain plan on the query and it shows that my cost is: 147,608.
Most of the cost is coming from a nested loop with survey_results and the question_PK_IDX.
I have tried some sub queries to see if I can speed up the query, but the cost increased on every attempt I made.
Any assistance would be great!
Thank you!