Good morning everyone,
iam having some problems with the following statement. The Subselect is moderately quick, but the whole statment takes about 70-75 seconds, which is unacceptable. Here are some facts you might need to know:
The statement is partly hardcoded and cant be changed (until the first WHERE). So i cant use a join rather than the IN+Subselect.
"EXISTS" only saves me a few seconds.
table consists of 1 million lines
idxmail consists of 2 million lines
matching consists of 10 000 lines
@var1 is set by the program
SELECT col1, col2
FROM table b
WHERE b.id IN (
SELECT id
FROM idxmail i
JOIN matching m ON i.proxyaddress = m.proxyaddress
WHERE m.mailnickname = '@var1')
The profile of this query has about 2 million lines aswell. One for each line in idxmail.
Explain (There is an index on id in table b):
"id" "select_type" "table" "type" "possible_keys" "key" "key_len" "ref" "rows" "Extra"
"1" "PRIMARY" "b" "ALL" NULL NULL NULL NULL "756831" "Using where"
"2" "DEPENDENT SUBQUERY" "i" "ref" "ID,Proxyadresse" "ID" "5" "func" "1" "Using where"
"2" "DEPENDENT SUBQUERY" "m" "ALL" NULL NULL NULL NULL "10" "Using where"
Thanks in advance.
iam having some problems with the following statement. The Subselect is moderately quick, but the whole statment takes about 70-75 seconds, which is unacceptable. Here are some facts you might need to know:
The statement is partly hardcoded and cant be changed (until the first WHERE). So i cant use a join rather than the IN+Subselect.
"EXISTS" only saves me a few seconds.
table consists of 1 million lines
idxmail consists of 2 million lines
matching consists of 10 000 lines
@var1 is set by the program
SELECT col1, col2
FROM table b
WHERE b.id IN (
SELECT id
FROM idxmail i
JOIN matching m ON i.proxyaddress = m.proxyaddress
WHERE m.mailnickname = '@var1')
The profile of this query has about 2 million lines aswell. One for each line in idxmail.
Explain (There is an index on id in table b):
"id" "select_type" "table" "type" "possible_keys" "key" "key_len" "ref" "rows" "Extra"
"1" "PRIMARY" "b" "ALL" NULL NULL NULL NULL "756831" "Using where"
"2" "DEPENDENT SUBQUERY" "i" "ref" "ID,Proxyadresse" "ID" "5" "func" "1" "Using where"
"2" "DEPENDENT SUBQUERY" "m" "ALL" NULL NULL NULL NULL "10" "Using where"
Thanks in advance.