I was having a massive problem with duplicate custom fields all named ‘views’ with a value of ’1′ on my blog.  By “massive” I mean over 1080 at the point I fixed the problem.

The custom field ‘views’ is used by the WP-PostViews plugin to keep track of how many times a post has been viewed.  This was desired, however unnecessary since Google Analytics is doing that nicely for me.  The undesired side-effect was that as the number of posts went up, the number of those duplicate fields would also increase.

These fields, mind you, were not stored in the database once I saved a post.  Nope.  They only existed when I created a new post.  The problem with having 1000+ of these, was that my browser would literally lock up while that the “New Post” page loaded.

Since I didn’t need that functionality inside my WordPress install, I disabled and completely deleted the plugin, but that didn’t fix the problem.

So I logged into my database (using phpMyAdmin or something similar) and after a quick bit of looking determined that the number of duplicate fields matched the number of ‘view’ fields whose value was ’1′.  Apparently the fields whose number was not ’1′ didn’t produce a duplicate on the new post page.

select count(*)
  from wp_postmeta
 where meta_key = 'views'
   and meta_value = '1'

Now, if I had intended to, at some point, revive that plugin on my blog; or if I wanted to keep the existing data; I wouldn’t do this next step exactly this way… I’d keep the “and meta_value = '1'” part of the previous query.  But since I didn’t, and since I’d already removed the plugin, I simply cleaned up the database.

delete
  from wp_postmeta
 where meta_key = 'views'

There. No more duplicate fields on the New Post page. It loads so much quicker now. :-)

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Calendar

September 2010
S M T W T F S
« Jul    
 1234
567891011
12131415161718
19202122232425
2627282930  

Archives

My Photography

Background image provided by
Jon Warren Photography
Photo taken at Bass Rock in
Ventura County, California.
© 2010 Jonathan D. Warren Disclaimer Suffusion WordPress theme by Sayontan Sinha