PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 21st, 2002, 11:15 AM
daan12 daan12 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: london
Posts: 2 daan12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
_pkey SOS!!!!




Hi,
there's beer in it for the person who solves this one.

I have a postgres database running under redhat which I access over a LAN through SSH.
I had a problem with a table a couple of weeks ago and simply copied over with an older version of that table which had fewer records in.

Silly me didn't realise that the _pkey table would consequently be screwed up
I discovered this through vacuumdb - here's what I got back -

------------------------------------------

NOTICE: Index profiles_pkey: NUMBER OF INDEX' TUPLES (989) IS NOT THE SAME AS HEAP' (821).
Recreate the index.
NOTICE: Index profiles_pkey: NUMBER OF INDEX' TUPLES (989) IS NOT THE SAME AS HEAP' (821).
Recreate the index.
-----------------------------------------------------------------------------------

my big question is therefore - How do I recreate the index?????????


any help would be much appreciated

Thanks

Reply With Quote
  #2  
Old June 23rd, 2002, 06:18 AM
Ted Striker Ted Striker is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 409 Ted Striker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Arrow

It sounds to me like the index is still referencing the old table, not the NEW one that you just copied over. That's why it's wack. Not to worry, nothing is broken; messing with indexes is usually pretty safe. There are several things we could do in this case.

First, here's the REINDEX command:

http://www.commandprompt.com/ppbook/r27795.htm

Here's an excerpt from the page, see the link above for a full description:

Quote:
Synopsis
REINDEX { TABLE | DATABASE | INDEX } name [ FORCE ]

Description
Use the REINDEX command to rebuild any indices that have become corrupt. This is especially useful if system indices become corrupted. To fix them, shutdown postmaster and start it using the -o "-O -P" command-line parameter. This opens a standalone server that allows for re-indexing of system indices. Run the REINDEX DATABASE command once you are at the psql prompt.


I am assuming in this case your command would be something like :

Quote:
REINDEX INDEX profiles_pkey;


But notice from the description above, you'll need to shut down Postgres and restart it in standalone mode, before running that command.

Usually I just drop and recreate indexes, unless they are insanely big, since it's usually pretty safe to drop them. But since I don't know if your index is a special kind of index, (like if it's a function based index) try out the REINDEX command above and let me know how it works out. If it doesn't then we can consider just dropping the thing and recreating it.

Some people even drop and recreate indexes now and then as a matter of performance tuning. (For example if you have a table with a alot of deletions in it, the index may not be optimized for that table).

Last edited by Ted Striker : June 23rd, 2002 at 06:40 AM.

Reply With Quote
  #3  
Old June 24th, 2002, 09:31 AM
daan12 daan12 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: london
Posts: 2 daan12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile Thanks

Thanks Ted,

That worked a treat - REINDEX INDEX profiles_pkey; created a new index for the profiles table and now I can update as previous.

Many many thanks


David

Reply With Quote
  #4  
Old June 24th, 2002, 03:18 PM
Ted Striker Ted Striker is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 409 Ted Striker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Thumbs up

Awesome!

Glad to hear that worked out for you.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > _pkey SOS!!!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT