Subject Re: [firebird-support] What is more effective execute block or select?
Author Svein Erling Tysvær
No, I must admit limited knowledge of MERGE. For Firebird 3 is seems like a good alternative, but I think Fb 2.1 and 2.5(?) requires a WHEN NOT MATCHED THEN INSERT clause (which is typically not desirable in these cases).

Set

2016-01-28 13:31 GMT+01:00 Mark Rotteveel mark@... [firebird-support] <firebird-support@yahoogroups.com>:
On Wed, 27 Jan 2016 23:01:50 +0100, "setysvar setysvar@...
[firebird-support]" <firebird-support@yahoogroups.com> wrote:

> [..] On the other hand, there are cases
> where EXECUTE BLOCK can help performance (note, I speak for 2.5, I know
> nothing about Firebird 3):
>
> UPDATE <HugeTable> h
> SET <AField> = (SELECT <AnotherField> FROM <TinyTable> t WHERE
> h.<SelectiveIndexedField> = t.<SomeField>)
>
> is much slower than
>
> EXECUTE BLOCK AS
> Declare variable a integer;
> Declare variable b integer;
> BEGIN
>    FOR SELECT DISTINCT <SomeField>, <AnotherField>
>    FROM <TinyTable>
>    INTO :a, :b do
>      UPDATE HugeTable
>         SET <AField> = :b
>         WHERE <SelectiveIndexedField> = :a;
> END

Out of curiosity: have you also compared this with using MERGE?

Mark


------------------------------------
Posted by: Mark Rotteveel <mark@...>
------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/firebird-support/join
    (Yahoo! ID required)

<*> To change settings via email:
    firebird-support-digest@yahoogroups.com
    firebird-support-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    firebird-support-unsubscribe@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/