Gossamer Forum
Home : Products : Links 2.0 : Discussions :

how to reorganise links.db

Quote Reply
how to reorganise links.db
hello,

I've searched through the forum but i did not find the answer to my question. could you please help me?

my database grew quite big, and therefore I'm wondering if there is a way to speed everything up, by reorganising the database.

f.eg. would it help to sort all the records by the link ID? I've noticed that not all are sorted incremental.

thanks a lot!
chris
Quote Reply
Re: [chris2002] how to reorganise links.db In reply to
How large is your database? Do you have many new fields, other than the default ones? I dont actually think that re-organising your database would help you much. You may want to consider doing a verify of links, to weed out dead ones too (its amazing how many of them you can find and not even know they were there Wink). Alternativly, you could upgrade to Links SQL Cool

Just a few ideas

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] how to reorganise links.db In reply to
thanks for your reply. well it is not really big actually, but I'm really wondering how the db should be to obtain best performance (even if will be a 0,000001 sec faster). any idea?

cheers!

check links -> thanks already done
Quote Reply
Re: [chris2002] how to reorganise links.db In reply to
>>would it help to sort all the records by the link ID?<<

It makes no difference. What would be the point of making it 0.00001 faster?

If you really want better performance, go with Links SQL

How big is your database?
Quote Reply
Re: [PaulW] how to reorganise links.db In reply to
nothing... it is curiosity. my db file is about 500K.
Quote Reply
Re: [chris2002] how to reorganise links.db In reply to
You can't do much to speed it up I'm afraid. The code is good, the way the data is stored is efficient (in terms of flat-file storage) so there is nothing else you can do really other than use SQL.
Quote Reply
Re: [chris2002] how to reorganise links.db In reply to
I don't know if this is what you mean but I thought about making a mod that will work like this.
You take linksid.txt and turn it back to 0 or whatever. Then the script would go put the db in an array, and then foreach line of the array(splitting the lines of course by links fields) change the ID's with the incremental $count++ or something like that and then print it back to the linksid.txt. I imagine this would be a really long process. This would make it so if you have lets say 10 links and they go
1, 3, 9, 7, 4, 82, 128, 345, 34, 23
lets say they got unorganized by deleting and modifying and a bad kept linksid.txt. It would go through and change them to 1-10

But of course, if you have link owners, this would be bad if you use a modify.cgi security thing that goes by ID, because their ID will change. If you use the newer mods like Paul's, this would work.

Lavon Russell
LookHard Mods
lavon@lh.links247.net

Last edited by:

Bmxer: Nov 24, 2001, 9:11 AM
Quote Reply
Re: [Bmxer] how to reorganise links.db In reply to
Shall I save you the trouble :)

Code:
my $i;
my @line;

open F, "</path/to/links.db" or die $!;
open O, ">/path/to/links.db.new" or die $!;
while (<F>) {
$i++;
chomp;
@line = split /\|/;
shift @line;
print O "$i|" . join("|", @line) . "\n";
}
close O;
close F;

open L, ">/path/to/linkid.txt" or die $!;
print L $i;
close L;

..that isn't tested but has a 75% chance of working Angelic



Last edited by:

PaulW: Nov 24, 2001, 9:21 AM
Quote Reply
Re: [PaulW] how to reorganise links.db In reply to
With a quick glance at that, it looks like it works good. Smile. Less for me to do.
Lavon Russell
LookHard Mods
lavon@lh.links247.net
Quote Reply
Re: [Bmxer] how to reorganise links.db In reply to
Someone better test :)
Quote Reply
Re: [PaulW] how to reorganise links.db In reply to
Ok i tested it Smile on my test db of about 112 links which reacheds of about 4000 because its only a test db and i don't care about resetting my linksid.txt. But yeah, it did everything and reordered the id's and it took approximately 1 second to do the 112 links.
Lavon Russell
LookHard Mods
lavon@lh.links247.net
Quote Reply
Re: [Bmxer] how to reorganise links.db In reply to
Cool
Quote Reply
Re: [Bmxer] how to reorganise links.db In reply to
Another flaw in doing something like this is if you offer external Mods (like External Rate It or Search Affliates type of mod) where the Link Owner uses their Link ID in forms (like rate it forms), then ratings will be screwed up and also it will be intensive on the Link Owner to continually edit their forms because their IDs constantly change using a script like this.
========================================
Buh Bye!

Cheers,
Me

Last edited by:

Heckler: Nov 24, 2001, 5:54 PM
Quote Reply
Re: [PaulW] how to reorganise links.db In reply to
um... I did an ID number regenerator hack several months ago. http://www.camelsoup.com/?view=id_regen

Could have saved yourlself some trouble by just linking to my site ;-)

--Philip
Links 2.0 moderator
Quote Reply
Re: [ThatPerson1024] how to reorganise links.db In reply to
Wasn't any trouble...took 5 mins to write and mine is better Tongue

Last edited by:

PaulW: Nov 25, 2001, 3:32 AM