Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 03-20-2002, 09:57 PM
Aaow AnD wHiTe's Avatar
Aaow AnD wHiTe Aaow AnD wHiTe is offline
 
Join Date: Dec 2001
Location: Barcelona, Spain
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default query to delete attachments bigger than 100 kb.

That's it

Does anyone how can we run a query that can delete attachments bigger than 100 kb?

We don't allow attachments bigger than 100kb, but we used to. We really need to get rid of those big attachments.

Thx in advance
Reply With Quote
  #2  
Old 03-21-2002, 05:44 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
DELETE FROM attachment WHERE LENGTH(filedata)>102400;
Reply With Quote
  #3  
Old 03-21-2002, 01:58 PM
Aaow AnD wHiTe's Avatar
Aaow AnD wHiTe Aaow AnD wHiTe is offline
 
Join Date: Dec 2001
Location: Barcelona, Spain
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thx Chen However, it seems like it hasn't reduced our db's size :-?
Reply With Quote
  #4  
Old 03-21-2002, 02:00 PM
Aaow AnD wHiTe's Avatar
Aaow AnD wHiTe Aaow AnD wHiTe is offline
 
Join Date: Dec 2001
Location: Barcelona, Spain
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, it shows the reduced size. Thx ^^
Reply With Quote
  #5  
Old 07-26-2002, 11:56 PM
Aaow AnD wHiTe's Avatar
Aaow AnD wHiTe Aaow AnD wHiTe is offline
 
Join Date: Dec 2001
Location: Barcelona, Spain
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just bumping this old thread to ask if anyone knows what query can we use to delete attachments from a specific sub-forum

We've used the Admin Functions hack by tubedogg but for some reason it doesn't reduce the total DB size in phpmyadmin or Freddie's Admin Quick Stats Hack :-?

Anyone?
Reply With Quote
  #6  
Old 05-07-2015, 12:10 PM
jaxo jaxo is offline
 
Join Date: Dec 2011
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Would this work with attachments stored on the file system ?
Reply With Quote
  #7  
Old 05-07-2015, 12:13 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This could be the record for bumping an old thread. What is it you're trying to do? A database query isn't going to remove files from the file system of course.
Reply With Quote
  #8  
Old 05-07-2015, 12:35 PM
jaxo jaxo is offline
 
Join Date: Dec 2011
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hahaha, Just saw the date of the last post lol

I`m running vbulletin 4.2.2, I have over 50Gb of attachments in the file system, A lot of them are no longer relevant and some are pretty big in size, .. I`m would like to delete all attachments over 50Mb but doing it manually in the control panel would take forever as there is 15000+

Jack
Reply With Quote
  #9  
Old 05-07-2015, 03:51 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You'd need a custom script I think, if you wanted to remove them from the database and from the file system. If you ran the above I'm not sure what would happen. You definitely wouldn't reclaim the file space unless you also removed the corresponding files form the filesystem yourself. Also, it wouldn't adjust everything that should be adjusted in the database, but that may or may not be a big deal, I'm not sure.
Reply With Quote
  #10  
Old 05-07-2015, 06:17 PM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you run the above query it will do nothing because in VB4.2.2, there is no filedata in the attachment table. KH99 is correct though, you will need a script that will query the filedata table for file sizes, filedataid, and userid. Then it will have to traverse the file system using the attachment folder hierarchy and delete the files and thumbs, then go back and "clean" the attachment and filedata tables as well as scrub the posts that reference the attachments if you want it to be done correctly. There may be a couple more tables to be adjusted as well, but I haven't researched it that much.
Reply With Quote
Reply

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:04 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04433 seconds
  • Memory Usage 2,232KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete