Subject | how to do union |
---|---|
Author | svanderclock |
Post date | 2009-12-08T09:45:43Z |
Hello,
i already ask a question about this, but this is a little different so i rather prefer to start a new thread
i need to do this Query
Select First 201 Skip 0
FieldC
FROM BigTable
WHERE
FieldA = 'FR' AND
FieldB = 56
PLAN (BIGTABLE order IndexOnFieldAAndFieldBAndFieldC)
ORDER BY FieldA,
FieldB,
FieldC
this work ok (< 50 ms) but now i need also to do
WHERE
FieldA = 'FR' OR FieldA = 'US'
big problem : very very slow (> 6 seconds)
so the idea is to do an "union" :
Select First 201 Skip 0
FieldC
FROM BigTable
WHERE
FieldA = 'FR' AND
FieldB = 56
PLAN (BIGTABLE order IndexOnFieldAAndFieldBAndFieldC)
ORDER BY FieldA,
FieldB,
FieldC
Union
Select First 201 Skip 0
FieldC
FROM BigTable
WHERE
FieldA = 'US' AND
FieldB = 56
PLAN (BIGTABLE order IndexOnFieldAAndFieldBAndFieldC)
ORDER BY FieldA,
FieldB,
FieldC
normally is can not take more than 100 ms to do it !
but it's not work :( probably i write badly the union ?
i must manually do the union in the software, mean firt do the first query an retrieve the data, then do the second query and retrieve the data, then mix the data myself... is it normal ? why the engine can not simply do what we ask him : the simple union ?
thanks for all
stephane
i already ask a question about this, but this is a little different so i rather prefer to start a new thread
i need to do this Query
Select First 201 Skip 0
FieldC
FROM BigTable
WHERE
FieldA = 'FR' AND
FieldB = 56
PLAN (BIGTABLE order IndexOnFieldAAndFieldBAndFieldC)
ORDER BY FieldA,
FieldB,
FieldC
this work ok (< 50 ms) but now i need also to do
WHERE
FieldA = 'FR' OR FieldA = 'US'
big problem : very very slow (> 6 seconds)
so the idea is to do an "union" :
Select First 201 Skip 0
FieldC
FROM BigTable
WHERE
FieldA = 'FR' AND
FieldB = 56
PLAN (BIGTABLE order IndexOnFieldAAndFieldBAndFieldC)
ORDER BY FieldA,
FieldB,
FieldC
Union
Select First 201 Skip 0
FieldC
FROM BigTable
WHERE
FieldA = 'US' AND
FieldB = 56
PLAN (BIGTABLE order IndexOnFieldAAndFieldBAndFieldC)
ORDER BY FieldA,
FieldB,
FieldC
normally is can not take more than 100 ms to do it !
but it's not work :( probably i write badly the union ?
i must manually do the union in the software, mean firt do the first query an retrieve the data, then do the second query and retrieve the data, then mix the data myself... is it normal ? why the engine can not simply do what we ask him : the simple union ?
thanks for all
stephane