472,330 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,330 software developers and data experts.

Triggers and COPY

Hi,

Is there any way to prevent a trigger from firing during a COPY operation?

We have a case where we dump the records from a table, truncate it, and
copy the records back in. However, there is a trigger on that table,
which will insert a record in a logging table. Is there a way to prevent
this trigger from firing during the COPY FROM process?

Just a little more background, I tried to make the function a little
more intelligent with OLD and NEW, but in the case of an INSERT, there
is no OLD, so there is no comparison.

Regards
- Ericson Smith
er**@did-it.com
Did-it.com
The Search Campaign Specialists
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #1
3 5580
Ericson Smith wrote:
Hi,

Is there any way to prevent a trigger from firing during a COPY operation?

We have a case where we dump the records from a table, truncate it, and
copy the records back in. However, there is a trigger on that table,
which will insert a record in a logging table. Is there a way to prevent
this trigger from firing during the COPY FROM process?


Can you drop the trigger during copy? I don't know following will exactly work
but something like..

begin
drop trigger
copy
recreate trigger
commit;

could do trick for you..

HTH

Shridhar
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #2
On Thursday 25 September 2003 16:06, Shridhar Daithankar wrote:
Ericson Smith wrote:
Hi,

Is there any way to prevent a trigger from firing during a COPY
operation?

We have a case where we dump the records from a table, truncate it, and
copy the records back in. However, there is a trigger on that table,
which will insert a record in a logging table. Is there a way to prevent
this trigger from firing during the COPY FROM process?


Can you drop the trigger during copy? I don't know following will exactly
work but something like..

begin
drop trigger
copy
recreate trigger
commit;

could do trick for you..


You might be able to do this with pg_restore too. That's got the ability to
disable triggers.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #3
Richard Huxton wrote:
On Thursday 25 September 2003 16:06, Shridhar Daithankar wrote:
Ericson Smith wrote:
> Hi,
>
> Is there any way to prevent a trigger from firing during a COPY
> operation?
>
> We have a case where we dump the records from a table, truncate it, and
> copy the records back in. However, there is a trigger on that table,
> which will insert a record in a logging table. Is there a way to prevent
> this trigger from firing during the COPY FROM process?


Can you drop the trigger during copy? I don't know following will exactly
work but something like..

begin
drop trigger
copy
recreate trigger
commit;

could do trick for you..


You might be able to do this with pg_restore too. That's got the ability to
disable triggers.


You probably want to do it a little finer grained, though still the way
pg_restore does it.

The trick is to do it all inside a transaction. At the beginning you
update pg_class and set the column reltriggers to zero. Then you do the
COPY, restore the old value of reltriggers and commit.

You want to modify pg_class for the relation in question only because
this whole trick creates 2 dead tuples in pg_class, and at some point it
hurts to inflate pg_class with massive amounts of dead tuples.
Jan

--
#================================================= =====================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================= = Ja******@Yahoo.com #
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Keith | last post by:
Not sure if anyone in here knows the answer to this, but I asked in a SQL group and haven't had a suitable answer and since the front end app is ASP...
7
by: Sjaak van Esdonk | last post by:
Hi all, i'm trying to find a solution for the following problem: I have two different database called A and B. On database A runs an...
3
by: Jonathan Bishop | last post by:
Hi. We are using MSDE2000 on a Point of Sale application. We need to keep a copy of a few key tables as up to date as possible for backup...
1
by: Gent | last post by:
am using FOR UPDATE triggers to audit a table that has 67 fields. My problem is that this slows down the system significantly. I have narrowed down...
1
by: jason_s_ford | last post by:
I have several sql server databases that were recently moved to a new server. In the process of migrating the databases, any triggers and...
2
by: Janning Vygen | last post by:
hi PGurus, i searched the archives and read the docs, because this problem shouldn't be new. But i really don't know what to search for. i am...
1
by: James Robinson | last post by:
Just a sanity check -- data fed into pg using the COPY tablename (col1, col2) FROM stdin; ... data \. Does not cause referential triggers to...
3
by: rick | last post by:
Hi I m new to DB2, Please bear with me if this is silly question, but i need to know how to copy(only triggers) 400 triggers from one data base...
11
by: Anthony Paul | last post by:
Hello everyone, I am involved in a scenario where there is a huge (SQL Server 2005) production database containing tables that are updated...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.