How is this qury executed
Hello!I just got an job/issue on my desk.
"Why does this query take so long to execute?"
To give you the complete info, we got at database Oracle 9i with a table a_tbl with over 10 000 000 rows.
Columns in a_tbl looks for eg: (id, name, mark)
We got a cronjob that updates some of these rows each night and insert a int in the column "mark".
The sql to fetch these rows looks like
select name from a_tbl
where name not in
(
"very complex select sql-query"
)
If I just execute the "very complex select sql-query" it returns after 2 minutes.
But if executed within the the total query it doesn't return until after 5 hours, acctually it has not returned yet.
So my question is if Oracle, or the total question is executed like
select name from a_tbl
for eache row, execute "very complex select sql-query"
or does it:
execute "very complex select sql-query" only once
and with this list above only select those "name" that is not in that list.
My guess is that it executes the "very complex select sql-query"
for each name.
Any comment is very welcome
Best regards
Fredrik