473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

converting FK's to "DEFERRABLE"

In order to try to reduce lock contention on my FK's, I need to
convert them to DEFERRABLE. The straightforward way is to drop and
recreate the modified FK. However, on a table with 65M rows, this is
taking quite some time. I'm afraid how long it will take to update
both FK's on my 170M+ row table...

Anyhow, is there some trickier way to make an FK deferrable? Mucking
with the system tables, perhaps?

I see that pg_restore has a way to turn off triggers during the data
load. If I can guarantee no updates to the table in question, can I
use that same code to disable triggers, drop+add the FK, then
re-enable triggers? Or will that not avoid the check when I create
the new FK?

I'd like to avoid a few hours of downtime while updating these
triggers.

Thanks.

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D. Khera Communications, Inc.
Internet: kh***@kciLink.com Rockville, MD +1-301-869-4449 x806
AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/

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

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

Nov 23 '05 #1
2 2004
Vivek Khera <kh***@kcilink.com> writes:
Anyhow, is there some trickier way to make an FK deferrable?


Hack its pg_constraint.condeferrable and pg_constraint.condeferred
fields (the latter is the INITIALLY DEFERRED flag). You will also
need to find the triggers that implement the constraint and update
their pg_trigger.tgdeferrable and pg_trigger.tginitdeferred copies
of these values. Then start fresh backend sessions and I think
you're there.

AFAIK the most reliable way to find the triggers is to follow the
linking entries in pg_depend.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #2

On Sep 17, 2004, at 3:27 PM, Tom Lane wrote:
Vivek Khera <kh***@kcilink.com> writes:
Anyhow, is there some trickier way to make an FK deferrable?


Hack its pg_constraint.condeferrable and pg_constraint.condeferred
fields (the latter is the INITIALLY DEFERRED flag). You will also
need to find the triggers that implement the constraint and update
their pg_trigger.tgdeferrable and pg_trigger.tginitdeferred copies
of these values. Then start fresh backend sessions and I think
you're there.


Thanks a bunch. This worked flawlessly. Basically I did this:

begin;
select pg_constraint.oid from pg_constraint,pg_class where
pg_constraint.conrelid=pg_class.oid and relname='mytable' and
conname='$1';
X=oid number
update pg_constraint set condeferrable='t' where oid=X;
update pg_trigger set tgdeferrable='t' where oid in (select objid from
pg_depend where refobjid=X);
commit;

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D. MailerMailer, LLC Rockville, MD
http://www.MailerMailer.com/ +1-301-869-4449 x806
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #3

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

Similar topics

4
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net...
29
by: Armand Karlsen | last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01 Transitional and CSS compliant, and I'm thinking of converting it into XHTML to learn a little about it. Which XHTML variant...
8
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
3
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application...
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 populating a database (v7.4.1) with COPY. Some...
2
by: Philippe Lang | last post by:
Hello, As the amount of simultaneous users of my database grows (25 users sometimes, PGSQL 7.4.5), deadlocks are unfortunately more and more frequent. I guess this is due to the FKs problem with...
7
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
8
by: Pumuky | last post by:
Hi all, I would need to know the way to get the FKs between two or more tables. Could you help me? Thank you in advance, Pumuky
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.