vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   query to delete attachments bigger than 100 kb. (https://vborg.vbsupport.ru/showthread.php?t=36366)

Aaow AnD wHiTe 03-20-2002 09:57 PM

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 :)

Admin 03-21-2002 05:44 AM

Code:

DELETE FROM attachment WHERE LENGTH(filedata)>102400;

Aaow AnD wHiTe 03-21-2002 01:58 PM

Thx Chen :) However, it seems like it hasn't reduced our db's size :-?

Aaow AnD wHiTe 03-21-2002 02:00 PM

Ok, it shows the reduced size. Thx ^^

Aaow AnD wHiTe 07-26-2002 11:56 PM

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?

jaxo 05-07-2015 12:10 PM

Would this work with attachments stored on the file system ?

kh99 05-07-2015 12:13 PM

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.

jaxo 05-07-2015 12:35 PM

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

kh99 05-07-2015 03:51 PM

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.

Replicant 05-07-2015 06:17 PM

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.


All times are GMT. The time now is 07:44 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01053 seconds
  • Memory Usage 1,722KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete