AW: [INTERFACES] Re: [HACKERS] changes in 6.4 - Mailing list pgsql-hackers

From Andreas Zeugswetter
Subject AW: [INTERFACES] Re: [HACKERS] changes in 6.4
Date
Msg-id 01BDD4DA.C7F5B690@zeugswettera.user.lan.at
Whole thread Raw
List pgsql-hackers
>Another idea would be to do actual UNION queries:
>
>    SELECT * FROM tab
>    WHERE (x=3 and y=4)
>    UNION
>    SELECT * FROM tab
>    WHERE (x=3 and y=5)
>    UNION
>    SELECT * FROM tab
>    WHERE (x=3 and y=6) ...
>
>This would work well for tables with indexes, but for a sequential scan,
>you are doing a sequential scan for each UNION.

The most important Application for this syntax will be M$ Access
because it uses this syntax to display x rows from a table in a particular
sort order. In this case x and y will be the primary key and therefore have a
unique index. So I think this special case should work good.

The strategy could be something like:
iff x, y is a unique index
    do the union access path
else
    do something else
done

I think hand written SQL can always be rewritten if it is not fast enough
using this syntax.

Andreas


pgsql-hackers by date:

Previous
From: Michael Meskes
Date:
Subject: Strange NOTICE
Next
From: korapat
Date:
Subject: UNION opration NOT return all result set :) pls help