Site Links
Home
Features
Documentation
Pricing & Order
Members Area
Support Options
UBBDev.com
UBBWiki.com
Who's Online
4 registered (mjuby, KuKuKaChu, tradge, Gizmo), 28 Guests and 15 Spiders online.
Key: Admin, Global Mod, Mod
Featured Member
Registered: Yesterday at
Posts: 1
Top Posters (30 Days)
Ruben 49
DennyP 24
Gizmo 24
Dunny 17
SteveS 14
AllenAyres 12
dbremer 10
drkknght00 9
SD 9
driv 8
Latest Photos
OK Corral Shoot Out
Testing
Basildon Train Station
Basildon Town Centre looking from the rounderbout
Basildon Town Square
Topic Options
#170712 - 12/20/06 03:36 PM Importer performance tweak
devnull Offline
stranger
Registered: 12/14/06
Posts: 7
I'm importing a few tens of thousands of topics with something like 1.3 million posts into ubb7, and it gets really slow as I get upwards of 30k topics. It looks to me like this is because sorting on b_number and using a LIMIT n, 21 to get the next block of 20 topics requires MySQL to filter and sort the entire list of n-1 topics to get to the nth one.

Wouldn't it be faster to pass the last-processed topic number instead of ordinal, and change the query to something like:

select * from ${PREFIX}Posts WHERE B_Topic = 1 AND B_Number > [the last one processed] ORDER BY B_Number ASC LIMIT 20

That runs very much faster on my test system.

Thanks,

-D
Top
Express Hosting
Express Hosting "We are the official hosting company of UBB.threads. Ask us about our free migration services to migrate your UBB.threads installation."
#170713 - 12/20/06 03:46 PM Re: Importer performance tweak [Re: devnull]
Rick Offline
Post-a-holic
Registered: 06/04/06
Posts: 10164
Loc: Aberdeen, WA
That very well may be a better route to go. I'll work on making that change as soon as I get a chance.
Top
#170849 - 12/21/06 08:32 PM Re: Importer performance tweak [Re: Rick]
devnull Offline
stranger
Registered: 12/14/06
Posts: 7
Hi Rick,

Here's the patch I applied to the importer script. It hasn't seen any real testing yet, but I figured it might be a good start. I also added an index on w3t_Posts (B_Topic, B_Number) which lets MySQL scan far fewer index rows to find topics, and in fact gets faster the closer it gets to the end.

Hope this proves useful.

-D

62a63,64
> $startPostID = get_input("startPostID","get","int");
> if(strlen($startPostID) < 1) { $startPostID = 0;}
771c773
< global $html, $dbh, $cgi, $dbh65, $dbprefix, $start, $config, $topics, $site_id, $graemlins;
---
> global $html, $dbh, $cgi, $dbh65, $dbprefix, $start, $config, $topics, $site_id, $graemlins, $startPostID;
788c790
< $limit = "$start,21";
---
> $limit = "21";
792a795
> AND B_Number > $startPostID
795a799
> //echo "<pre> $query</pre><br/><br/>\n";
827a832,834
>
> // remember this topic's ID
> $endID = $topic_data['B_Number'];
1083c1090
< transition("Continuing...", "threads_import.php?ubb=posts&start=$end", 1);
---
> transition("Continuing...", "threads_import.php?ubb=posts&start=$end&startPostID=$endID", 1);
Top



Moderator:  AllenAyres, Harold, Ian, Ron M 
Shout Box

Today's Birthdays
No Birthdays
Recent Topics
Ability to "like" individual posts (not Facebook "likes)
by doug
09:03 AM
Island Permissions
by ThreadsUser
05/22/12 03:03 PM
streaming video
by prkrgrp
05/20/12 07:02 PM
New Posts Corrupted? Can someone help?
by PianoWorld
05/19/12 09:41 AM
Custom forum permissions
by ntdoc
05/18/12 02:07 PM
Forum Stats
10489 Members
36 Forums
33841 Topics
181695 Posts

Max Online: 978 @ 06/24/07 11:19 PM
Random Image