Suppression "Please Note: There is a relationship" when using "CREATE ... IF NOT EXISTING"

I have a function that creates a temporary table for storing and processing data. The problem is that I want to run this function about 1M times in a single transaction without having:

NOTICE:  relation "foo" already exists, skipping

output ~ 1M times. Is there an effective way to do this?

Which is inefficient:

  • Deleting a table instead

    DROP TABLE IF EXISTS
    
    • Leads from shared memory
  • Duplicate_table exception catch (less efficient than using IF NOT EXISTS?)

    BEGIN
        CREATE TEMPORARY TABLE foo () ON COMMIT DROP;
    EXCEPTION
        WHEN duplicate_table THEN --do nothing
    END;
    
+4
source share
2 answers

As others have pointed out, customization client_min_messagesis what you want. There are several ways to configure this setting.

SET client_min_messages = error; /.

SELECT set_config('client_min_messages', 'error', true); .

CREATE FUNCTION statement SET ; . :

CREATE FUNCTION f()
  RETURNS void
  SET client_min_messages = error
  LANGUAGE plpgsql
  AS ...
+8

SET client_min_messages = error;

().

psql

PGOPTIONS="-c client_min_messages=error" psql -f somefile.sql dbname
+1

All Articles