DBClean
DBClean
Some time ago, i wrote upon request a plugin to clean the database. Development stopped after i got suddenly no feedback anymore, so i forgot it myself. Well, i remembered and finished it today. Have a look, i will commit it to spartacus soon if no error-reports arrive here.
- Attachments
-
- serendipity_event_dbclean-0.2.tar.gz
- (2.64 KiB) Downloaded 259 times
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: DBClean
Hi!
Great, thanks for sharing! One thing I see is that you use unix_timestmap(). Could you use simple INT casting with PHP timestamps? This would make it possible to use on other DB systems like pgsql and sqlite...
Like this:
I also saw some strings like "Delete?" and "all entries" which were not yet put into constants.
And then ,please feel free to put it into spartacus. What about maybe merging this into the dashboard plugin?
Regards,
Garvin
Great, thanks for sharing! One thing I see is that you use unix_timestmap(). Could you use simple INT casting with PHP timestamps? This would make it possible to use on other DB systems like pgsql and sqlite...
Like this:
Code: Select all
$sql = "DELETE
FROM {$serendipity['dbPrefix']}$table
WHERE timestamp < " . (time()-($days*24*60*60));
And then ,please feel free to put it into spartacus. What about maybe merging this into the dashboard plugin?
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: DBClean
Thanks, i oversaw the headings. Fixed, also unix_timestamp().
Are there additional tables the plugin could clean?
However, it might work to use the dashboard-plugin to notify the user that a table is "full".
Are there additional tables the plugin could clean?
I don't really see the connection between those? To clean the database is a distinct purpose, think that belongs into an own plugin.What about maybe merging this into the dashboard plugin?
However, it might work to use the dashboard-plugin to notify the user that a table is "full".
- Attachments
-
- serendipity_event_dbclean-0.2.1.tar.gz
- (2.66 KiB) Downloaded 244 times
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: DBClean
Hi!
Hm, there are no other tables that come to my mind...
About dashboard: this more and more becomes a global "maintenance" and "notification" plugin, so maybe that we could even merge the autoupdater plugin into there?
Regards,
Garvin
Hm, there are no other tables that come to my mind...
About dashboard: this more and more becomes a global "maintenance" and "notification" plugin, so maybe that we could even merge the autoupdater plugin into there?
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
- Regular
- Posts: 764
- Joined: Fri Aug 12, 2005 4:36 pm
- Location: Grüt, Zürich, Switzerland
- Contact:
Re: DBClean
I have about 400.000 entries in "exit" and 1.500.000 in "visitors".onli wrote:Are there additional tables the plugin could clean?
Deleting a lot of entries in these tables can lead to a timeout, so I recommend doing a query before to decide how many entries would be deleted. Since this is based on time, there should be an index on the timestamp column.
Cheers
Dirk
Re: DBClean
I added exits, visitors was already in the selection.I have about 400.000 entries in "exit" and 1.500.000 in "visitors".
I'd be prefer not to mess with the database-structure with the plugin. Is the index something that should be generated by the creator of these tables?Since this is based on time, there should be an index on the timestamp column.
Hm, i don't like the idea of merging these plugins together. Merging would create one very big plugin, and the functionality is quite distinct... Yes, the dashboard-plugin is a global notification-area. And it is quite nice to offer a "react on this" to a notification when already in an admin-area. But the functionality itself don't have to be part of the dashboard-plugin for that to achieve.About dashboard: this more and more becomes a global "maintenance" and "notification" plugin, so maybe that we could even merge the autoupdater plugin into there?
Maybe the dashboard-plugin should have a hook for adding generic notifications to it, kind of a duplicate of backend_frontpage_display (but when the dasboard is on, we know the user wants to use the dashboard-area).
-
- Regular
- Posts: 764
- Joined: Fri Aug 12, 2005 4:36 pm
- Location: Grüt, Zürich, Switzerland
- Contact:
Re: DBClean
I added quite some indexes which came out of the analysis of the slow query log. This is normal optimisation work.onli wrote:I'd be prefer not to mess with the database-structure with the plugin. Is the index something that should be generated by the creator of these tables?
Cheers
Dirk
Re: DBClean
I just commited the plugin.
Dirk, it is perfectly fine to add those indexes on a blog you administrate yourself. But, if not absoluteley necessary, i don't want to change the db with a plugin - maybe some other plugin wants also to create an index on timestamp and chooses another name or something like that.
That's why i asked if the index is always a good idea, because then it would be possible to create the index when creating the table, in the proper place. If the missing index really creates problems, we should check that way.
Dirk, it is perfectly fine to add those indexes on a blog you administrate yourself. But, if not absoluteley necessary, i don't want to change the db with a plugin - maybe some other plugin wants also to create an index on timestamp and chooses another name or something like that.
That's why i asked if the index is always a good idea, because then it would be possible to create the index when creating the table, in the proper place. If the missing index really creates problems, we should check that way.