pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to get FK to use new index without restarting the database
7+ messages / 5 participants
[nested] [flat]
* How to get FK to use new index without restarting the database
@ 2010-12-16 12:12 Eric Comeau <ecomeau@signiant.com>
2010-12-16 12:34 ` Re: How to get FK to use new index without restarting the database Jayadevan M <Jayadevan.Maymala@ibsplc.com>
2010-12-16 12:39 ` Re: How to get FK to use new index without restarting the database Richard Huxton <dev@archonet.com>
2010-12-16 16:27 ` Re: How to get FK to use new index without restarting the database Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 3 replies; 7+ messages in thread
From: Eric Comeau @ 2010-12-16 12:12 UTC (permalink / raw)
To: pgsql-performance
Is there a way force the db to re-evaluate its execution plan for a FK
without bouncing the DB?
PostgreSQL 8.1.17
In our latest release our developers have implemented some new foreign
keys but forgot to create indexes on these keys.
The problem surfaced at one of our client installs where a maintenance
DELETE query was running for over 24 hrs. We have since then identified
the missing indexes and have sent the client a script to create them,
but in our testing we could not been able to get postgres to use the new
index for the FK cascade delete without bouncing the database.
Here is an example of an added fk but missing index....
ALTER TABLE scheduled_job_arg ADD CONSTRAINT sjr_scheduled_job_id_fk
FOREIGN KEY (scheduled_job_id) REFERENCES scheduled_job (id)
ON UPDATE CASCADE ON DELETE CASCADE;
Thanks in Advance,
Eric
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get FK to use new index without restarting the database
2010-12-16 12:12 How to get FK to use new index without restarting the database Eric Comeau <ecomeau@signiant.com>
@ 2010-12-16 12:34 ` Jayadevan M <Jayadevan.Maymala@ibsplc.com>
2010-12-16 12:55 ` Re: How to get FK to use new index without restarting the database Eric Comeau <ecomeau@signiant.com>
2 siblings, 1 reply; 7+ messages in thread
From: Jayadevan M @ 2010-12-16 12:34 UTC (permalink / raw)
To: Eric Comeau <ecomeau@signiant.com>; +Cc: pgsql-performance; pgsql-performance-owner@postgresql.org
Hello,
> Is there a way force the db to re-evaluate its execution plan for a FK
> without bouncing the DB?
>
> PostgreSQL 8.1.17
>
> In our latest release our developers have implemented some new foreign
> keys but forgot to create indexes on these keys.
>
> The problem surfaced at one of our client installs where a maintenance
> DELETE query was running for over 24 hrs. We have since then identified
> the missing indexes and have sent the client a script to create them,
> but in our testing we could not been able to get postgres to use the new
> index for the FK cascade delete without bouncing the database.
Did you try analyze? May be it will help.
http://www.postgresql.org/docs/9.0/static/sql-analyze.html
Regards,
Jayadevan
DISCLAIMER:
"The information in this e-mail and any attachment is intended only for
the person to whom it is addressed and may contain confidential and/or
privileged material. If you have received this e-mail in error, kindly
contact the sender and destroy all copies of the original communication.
IBS makes no warranty, express or implied, nor guarantees the accuracy,
adequacy or completeness of the information contained in this email or any
attachment and is not liable for any errors, defects, omissions, viruses
or for resultant loss or damage, if any, direct or indirect."
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get FK to use new index without restarting the database
2010-12-16 12:12 How to get FK to use new index without restarting the database Eric Comeau <ecomeau@signiant.com>
2010-12-16 12:34 ` Re: How to get FK to use new index without restarting the database Jayadevan M <Jayadevan.Maymala@ibsplc.com>
@ 2010-12-16 12:55 ` Eric Comeau <ecomeau@signiant.com>
0 siblings, 0 replies; 7+ messages in thread
From: Eric Comeau @ 2010-12-16 12:55 UTC (permalink / raw)
To: Jayadevan M <Jayadevan.Maymala@ibsplc.com>
On 10-12-16 07:34 AM, Jayadevan M wrote:
> Hello,
>> Is there a way force the db to re-evaluate its execution plan for a FK
>> without bouncing the DB?
>>
>> PostgreSQL 8.1.17
>>
>> In our latest release our developers have implemented some new foreign
>> keys but forgot to create indexes on these keys.
>>
>> The problem surfaced at one of our client installs where a maintenance
>> DELETE query was running for over 24 hrs. We have since then identified
>> the missing indexes and have sent the client a script to create them,
>> but in our testing we could not been able to get postgres to use the new
>
>> index for the FK cascade delete without bouncing the database.
> Did you try analyze? May be it will help.
> http://www.postgresql.org/docs/9.0/static/sql-analyze.html
Yes we did. Thanks for the suggestion.
>
> Regards,
> Jayadevan
>
>
>
>
>
> DISCLAIMER:
>
> "The information in this e-mail and any attachment is intended only for
> the person to whom it is addressed and may contain confidential and/or
> privileged material. If you have received this e-mail in error, kindly
> contact the sender and destroy all copies of the original communication.
> IBS makes no warranty, express or implied, nor guarantees the accuracy,
> adequacy or completeness of the information contained in this email or any
> attachment and is not liable for any errors, defects, omissions, viruses
> or for resultant loss or damage, if any, direct or indirect."
>
>
>
>
>
>
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get FK to use new index without restarting the database
2010-12-16 12:12 How to get FK to use new index without restarting the database Eric Comeau <ecomeau@signiant.com>
@ 2010-12-16 12:39 ` Richard Huxton <dev@archonet.com>
2 siblings, 0 replies; 7+ messages in thread
From: Richard Huxton @ 2010-12-16 12:39 UTC (permalink / raw)
To: Eric Comeau <ecomeau@signiant.com>; +Cc: pgsql-performance
On 16/12/10 12:12, Eric Comeau wrote:
>
> The problem surfaced at one of our client installs where a maintenance
> DELETE query was running for over 24 hrs. We have since then identified
> the missing indexes and have sent the client a script to create them,
> but in our testing we could not been able to get postgres to use the new
> index for the FK cascade delete without bouncing the database.
Well, an ongoing DELETE isn't going to see a new index. I'd have thought
a new connection should though.
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get FK to use new index without restarting the database
2010-12-16 12:12 How to get FK to use new index without restarting the database Eric Comeau <ecomeau@signiant.com>
@ 2010-12-16 16:27 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-12-16 16:46 ` Re: How to get FK to use new index without restarting the database Eric Comeau <Eric.Comeau@signiant.com>
2010-12-17 06:53 ` Re: How to get FK to use new index without restarting the database Eric Comeau <ecomeau@signiant.com>
2 siblings, 2 replies; 7+ messages in thread
From: Tom Lane @ 2010-12-16 16:27 UTC (permalink / raw)
To: Eric Comeau <ecomeau@signiant.com>; +Cc: pgsql-performance
Eric Comeau <ecomeau@signiant.com> writes:
> Is there a way force the db to re-evaluate its execution plan for a FK
> without bouncing the DB?
> PostgreSQL 8.1.17
You don't need to bounce the whole DB, but you will need to start fresh
sessions. We didn't add automatic invalidation of those plans until 8.3.
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get FK to use new index without restarting the database
2010-12-16 12:12 How to get FK to use new index without restarting the database Eric Comeau <ecomeau@signiant.com>
2010-12-16 16:27 ` Re: How to get FK to use new index without restarting the database Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-12-16 16:46 ` Eric Comeau <Eric.Comeau@signiant.com>
1 sibling, 0 replies; 7+ messages in thread
From: Eric Comeau @ 2010-12-16 16:46 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-performance
On 10-12-16 11:27 AM, Tom Lane wrote:
Eric Comeau <ecomeau@signiant.com> <mailto:ecomeau@signiant.com> writes:
> Is there a way force the db to re-evaluate its execution plan for a FK
> without bouncing the DB?
> PostgreSQL 8.1.17
You don't need to bounce the whole DB, but you will need to start fresh
sessions. We didn't add automatic invalidation of those plans until 8.3.
regards, tom lane
We confirmed that disconnecting and reconnecting resolves the issue.
Thanks to all that helped.
Eric
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: How to get FK to use new index without restarting the database
2010-12-16 12:12 How to get FK to use new index without restarting the database Eric Comeau <ecomeau@signiant.com>
2010-12-16 16:27 ` Re: How to get FK to use new index without restarting the database Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-12-17 06:53 ` Eric Comeau <ecomeau@signiant.com>
1 sibling, 0 replies; 7+ messages in thread
From: Eric Comeau @ 2010-12-17 06:53 UTC (permalink / raw)
To: pgsql-performance
On 10-12-16 11:27 AM, Tom Lane wrote:
> Eric Comeau<ecomeau@signiant.com> writes:
>> Is there a way force the db to re-evaluate its execution plan for a FK
>> without bouncing the DB?
>
>> PostgreSQL 8.1.17
>
> You don't need to bounce the whole DB, but you will need to start fresh
> sessions. We didn't add automatic invalidation of those plans until 8.3.
>
> regards, tom lane
>
We confirmed that disconnecting and reconnecting resolves the issue.
Thanks to all that helped.
I replied to Tom and the list yesterday from my e-mail, but I don't see
my reply here, so it must be stuck in the ether somewhere....
Eric
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2010-12-17 06:53 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-12-16 12:12 How to get FK to use new index without restarting the database Eric Comeau <ecomeau@signiant.com>
2010-12-16 12:34 ` Jayadevan M <Jayadevan.Maymala@ibsplc.com>
2010-12-16 12:55 ` Eric Comeau <ecomeau@signiant.com>
2010-12-16 12:39 ` Richard Huxton <dev@archonet.com>
2010-12-16 16:27 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-12-16 16:46 ` Eric Comeau <Eric.Comeau@signiant.com>
2010-12-17 06:53 ` Eric Comeau <ecomeau@signiant.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox