Project

General

Profile

« Previous | Next » 

Revision 11827

schemas/vegbien.sql: _taxonlabel_set_parent_id(): just use a plain UPDATE statement, to avoid the significant parsing and stringification overhead of EXECUTE and quote_nullable(). it is not clear that EXECUTE is actually necessary to avoid caching the query plan, because the cache should be invalidated automatically when the table's ANALYZE statistics are regenerated.

View differences:

vegbien.sql
626 626
--
627 627

  
628 628
CREATE FUNCTION _taxonlabel_set_parent_id(taxonlabel_id integer, parent_id integer) RETURNS integer
629
    LANGUAGE plpgsql
630
    AS $$
631
BEGIN
632
    -- Use EXECUTE to avoid caching query plan
633
    EXECUTE '
634
    UPDATE taxonlabel SET parent_id = '||quote_nullable(parent_id)||'
635
    WHERE taxonlabel_id = '||quote_nullable(taxonlabel_id)||'
636
    ';
637
    
638
    RETURN taxonlabel_id;
639
END;
640
$$;
629
    LANGUAGE sql
630
    AS $_$
631
UPDATE taxonlabel SET parent_id = $2 WHERE taxonlabel_id = $1 RETURNING $1
632
$_$;
641 633

  
642 634

  
643 635
--

Also available in: Unified diff