Subject Coalesce with Full join very slow
Author gig_boy4ever
Hi, i have problem with some queries,
I have 2000 record on a table called ATB, and I have a view called AVW,
this will select ATB with some parameter, so the view will be like this:

CREATE VIEW AVW (..)
AS
SELECT ATB.*, 'IN' FROM ATB WHERE ATB.STATE = 1
UNION ALL
SELECT ATB.*, 'OUT' FROM ATB WHERE ATB.STATE = 3

There is nothing wrong with the queries, and i can excecute the
statement below 0.1 seconds, but with longer fetch time because I'm
using MITEC IBQuery.
The problem is when I want to do this query:

SELECT
AVW.
COALESCE(
(SELECT AVW.QTY FROM AVW WHERE AVW.ID = AVW1.ID)
,0)
FROM AVW AVW1

This simple query is executed in > 2 seconds and I never know the exact
fetch time on IBQuery because it just to long to wait and when I use
IBOConsole, it also not responding. I tried not to use Coalesce but it
is the same, but when I remove the Correlated column, it can executed in
less than 0.1 seconds, because it just the same as selecting the view
only. What is the problem? And can you tell me more about Correlated
Column? Thank for the help

GB4EVER



[Non-text portions of this message have been removed]