Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 06-04-2010, 09:48 PM
sybakaos sybakaos is offline
 
Join Date: Mar 2006
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Joined table update query

Hello,

I've ran a thread prefixes mod since 2007. Now that I have moved to vB4 I no longer wish to use it or modify that mod to become compatible, nor do I wish to use vB4's prefix system. The mod added a new field in the tread table called threadprefix. I no longer wish to this prefix system and have thus performed a query that copied the prefix from thread.threadprefix to thread.title:

update thread set title = CONCAT(threadprefix,' - ',title) where threadprefix !=''

That worked well, the query changed 400,000+ thread titles in 300 seconds. However, I'd also like to update the post title of each first post with the prefix and came up with the following possibilities:

update post left join thread on thread.firstpostid = post.postid set post.title = CONCAT(thread.threadprefix,' - ',post.title) where thread.threadprefix !='' and thread.firstpostid = post.postid

or

update post left join thread on thread.firstpostid = post.postid set thread.title = post.title where thread.threadprefix !='' and thread.firstpostid = post.postid

These queries literally take 2-4 seconds/thread or 1,2 million seconds but do what is intended. My question, is there a faster way? I really don't want to close the board for 14 days...

Ofcourse I can simply not run the query, but in that case the threads are not findable when searching for the prefix as a keyword (even after reindexing posts). The alternative, is there a way to reindex thread titles?

Thanks for any help!

Greets,
syba
Reply With Quote
  #2  
Old 04-18-2011, 07:58 PM
sybakaos sybakaos is offline
 
Join Date: Mar 2006
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If anyone wonders, I've executed the query. I've waited 13 days and 2 hours for the query to finish, and I didn't even close the board nor ran into problems. Patience prevails.
Reply With Quote
  #3  
Old 04-18-2011, 08:05 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

13 days.... how many posts? wow.
Reply With Quote
  #4  
Old 04-18-2011, 08:33 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, I'd also be curious in knowing that.
Reply With Quote
  #5  
Old 04-18-2011, 08:35 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There are two things that would have speeded that up.

1. Index firstpostid in the thread table (remove it again afterwards if you wanted).

2. Remove the thread.threadprefix !='' - you already did that in the first query - so although it means all your titles would be updated, they would all be correct, and you would have removed a "where" clause thats slowing down the query.
Reply With Quote
  #6  
Old 04-18-2011, 08:57 PM
sybakaos sybakaos is offline
 
Join Date: Mar 2006
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There were 400,000 threads with a thread prefix and those threads had about 6,500,000 replies. The board has a total of 8.8 million posts.

I'm by no means an expert, and I've constructed the above queries from reading MySQL documentation. I'm quite proud at myself for accomplishing that, at least. I hoped to gain replies here and at other boards, but my requests for help ended in vain. I finally executed the query early this month and to my delight it was a critical success. I'm running on a 12xSAS and 16GB RAM server. I think it was just a really ineffective, albeit working, query and not a server issue.

If anyone still has the old thread prefixes, the above queries with Paul's touch may help you reset the thread and post titles, which is very useful if you use SEO products. Good luck!
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 08:48 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.03884 seconds
  • Memory Usage 2,195KB
  • Queries Executed 11 (?)
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)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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_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