New answers tagged

2 votes
Accepted

How to catch a particular exception?

In the exception handler, you can get the name of the violated constraint: DECLARE c text; BEGIN BEGIN ... EXCEPTION WHEN unique_violation THEN GET STACKED DIAGNOSTICS c = ...
Laurenz Albe's user avatar
  • 51.6k
1 vote
Accepted

Using dbeaver and postgresql can I declare a variable INTERVAL to pass into a sproc?

I did the following (fiddle here): CREATE TABLE events ( event TEXT, event_time TIMESTAMP ); and then: CREATE OR REPLACE FUNCTION insert_event ( in_event TEXT, in_interval ...
Vérace's user avatar
  • 29.9k
1 vote

How to pass an array to trigger function in TG_ARGV?

@bjmc this is what you should have done: CREATE OR REPLACE FUNCTION example_function() RETURNS TRIGGER AS $$ DECLARE special_names text[]; special_users text[]; BEGIN special_names := ...
xpusostomos's user avatar
0 votes

Function performance is worse than raw query in PostgreSQL

The difference between your two EXPLAIN ANALYZE's is only 121 microseconds, which is extremely tiny. EXPLAIN ANALYZE has some overhead, and on such fast queries, other overhead like network and ...
bobflux's user avatar
  • 1,486
1 vote
Accepted

Function performance is worse than raw query in PostgreSQL

Table valued SQL functions are not cached in any way, so from a performance perspective, this is a net loss. There are two things you can consider: writing a PL/pgSQL function, which will use a ...
Laurenz Albe's user avatar
  • 51.6k

Top 50 recent answers are included