May 4, 2011

Mass Delete: SQL... | Freeware Plugins | Support Forum

Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_TopicIcon
Mass Delete: SQL...
Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 (0 votes) 
July 26, 2012
4:23 pm
Avatar
wduser
Guest
Guests

Can you give me the SQl necessary to delete all posts containing the word "apples?" For example, I can run 

DELETE FROM wp_posts WHERE post_content LIKE '%apples%';

but that doesnt delete all rows from all tables related to wp_post.id

Help!

(mass delete works fine, but I figure that running the sql would be quicker)

Thanks!

July 26, 2012
4:32 pm
Avatar
CyberSEO
Admin
Forum Posts: 3949
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

The simple SQL query would not be quicker just because it won't work correct. You must use API functions only (find more info Login to see this link).

July 27, 2012
4:29 pm
Avatar
wduser
Guest
Guests

Thats part of my point :)

I attempt to Mass Delete about 700 posts daily, but on Thursdays, Fridays and Saturdays, the number of posts I have to delete increases well past 2500 posts for each day which tends to cause the script to fail and not stop processing.

And worse, the script doesnt stop running and tends to hang the server.

That led me to start looking for ways to do the same thing in MYSQL:

DELETE FROM wp_posts WHERE post_content LIKE '%apples%' <--- gets rid of the posts, then

DELETE FROM wp_postmeta WHERE NOT EXISTS (SELECT * FROM wp_posts WHERE wp_postmeta.post_id = wp_posts.ID) <--- removes the postmeta.

Those two SQL statements take about 5 seconds to run in total without hangs. But they do NOT remove the rows from the comments or the categories (doesn't decrease the category count either).

I looked at your reference and that would seem to work but if your plugin is based on it, I would assume that anything I attempt to do would fail in the same manner.

Is there anything you can do to keep the script from hanging? I dunno...have the script handle a much smaller amount of data and they restart itself? Like process 25 requests at a time according to what the user selects on the admin page and then restart...? That would probably work because for "smaller" amounts of data to process, it works flawlessly. So Im guessing that if you can help me "decrease" the amount of data its trying to process at the same time and then restart it? It would work 100% for me...

I appreciate any help you can give me in this effort.

July 27, 2012
4:36 pm
Avatar
wduser
Guest
Guests

Im on WP 3.3x by the way

July 27, 2012
4:41 pm
Avatar
CyberSEO
Admin
Forum Posts: 3949
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

Sorry but I can do nothing. The script uses standard WordPress Login to see this link) you will see why it's so slow.

Thus if you're asking me if I can improve the original WordPress function, my answer is not, I can't do that. You can use a simple MySQL query to remove the group of post almost instantly, but it will work incorrectly because a lot of garbage (linked comments, categories, attachments, metadata etc) will be left in the database.

Furthermore, WordPress team may change the internal database structure at any time and your MySQL query will stop working or can even break the whole database. The only way to avoid these problems is to use standard WordPress API functions only.

July 27, 2012
4:47 pm
Avatar
wduser
Guest
Guests

Thank you for the quick reply! :) :) :)

I understand completely.

However, can you make the script run on only a certain amount of posts, then restart? That would keep the server from hanging...

Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 541

Currently Online:
10 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

ninja321: 84

s.baryshev.aoasp: 68

Freedom: 61

Pandermos: 54

MediFormatica: 49

B8europe: 48

Member Stats:

Guest Posters: 337

Members: 2855

Moderators: 0

Admins: 1

Forum Stats:

Groups: 1

Forums: 5

Topics: 1641

Posts: 8356

Newest Members:

samuel2288, comercios.cercademi, wanmarkets, torontomark48, info.ckmedianetwork, contact.mybeautystar

Administrators: CyberSEO: 3949