Log in

View Full Version : Dual databases


Martz
02-01-2002, 10:46 AM
My co-developer and I are working on using 2 mySQL databases for vB - to lighten the load on attachments. We've run into some teething problems replicating the $DB_site-> function ($DB_attach->)

Is it possible to use 2 databases at once? Is it known to cause problems? Should we close the connections to 1 db before quering the other?

Thanks for any help.

Admin
02-01-2002, 11:32 AM
If you are using the same user/pass for the two databases, it's really simple actually. :)

All you need to do, is first move the attachment table from one db to the other.
Then, find all places where you have SELECT [...] FROM attachment, and change that to newDBname.attachment (also do that for JOINs with the attachment table).

The places I can currently think about are:
showthread.php (where you select the posts there should be a reference there to that table)
attachment.php (duh)
functions.php (acceptupload() is the function that actually adds the files to the database...)

Good luck. :)

Admin
02-01-2002, 11:34 AM
(And if you don't have the same user/pass for the databases, first yell at your host for being dense, then... I don't know. :))

Martz
02-02-2002, 12:08 AM
The problem is it's not on the same server. 2 different databases on 2 different servers. So if i'm not mistaken your solution would only help if the 2 db's are on the same server?

Thanks

Admin
02-02-2002, 05:17 AM
Yup... heh I was wondering how it would help to have two databases on the same servers rather than one. :)

In that case, just copy the code from global.php that starts $DB_site, and duplicate it using $DB_attach... then use that new object when selecting stuff from attachment table, although you will have problems with JOINs.

Martz
02-02-2002, 08:48 PM
Yeah - we're looking at re-writting these queries now, which I am guessing will make it less effcient - but we'll see when we get there. :)