Hi,
I got involved in a project that, apart from a ton of spaghetti code,
has something they call "db split functionality." NOTE: this is in no
way table partitioning and the longest table In short it means they have
several clones of the database (on the same server) with the same
structure but different set of data. The piece of code that takes care
of switching between the databases is below.
I was told the data has been distributed to decrease the server load. In
the meantime there appearead a bunch of (id) inconsistencies between the
data in the clones and other non-cloned parts of the database (ids in
serialized data &c).
- From the start the solution to the problem of high server load by
shortening the table content seemed outlandish. It is done by
arbitrarily assigning parts of uniformly structured data to various
database clones. Never mind that the table structure and indexing are,
well, undesigned. Variable lengths everywhere, 20+ columns a table, no
constraints or relations, boolean values done with 'yes'/'no' enums,
stuff like this.
I am already dizzy because of this project (no we can't refactor or
overhaul, because we have deadlines and new dev are coming to learn this
big ball of mud) so my question to you is:
is the "db split functionality" as crazy as I think or am I going crazy?
IMO the proper design and indexing would have been sufficient to reduce
the server load (seek times mostly). But I am really starting to doubt
if the Earth is round... Please help.
Here's a part of the php "code" that goes about "db splitting".
class Item {
<- snip ->
// this func takes care of the db split functionality
function _changeUserDB()
{
global $_dbDetails, $connCounter;
if(trim($this->config_dbase_prefix)=='')
return;
$_dbDetails['name']=$this->config_dbase_prefix;
$this->userDbx='`'.$this->config_dbase_prefix.'`.';
$this->_connect(); // just in case, we do it over;
}
<- snip ->
function _connect()
{
global $_dbDetails;
if(isset($this))
{
$this->_dbLink =
mysql_connect($_dbDetails['host'],$_dbDetails['user'],$_dbDetails['pass']);
mysql_select_db($_dbDetails['name'],$this->_dbLink);
}
else
{
$dbLink =
mysql_connect($_dbDetails['host'],$_dbDetails['user'],$_dbDetails['pass']);
mysql_select_db($_dbDetails['name'],$dbLink);
}
<- snip ->
}
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iF4EAREIAAYFAk0fW7kACgkQfD3PECtxdkXpYAD+KtzJJPC1toET/Jr6T8Ikr7HY
rh4Pvn2H03JUfu4BMW8A/jdzzh6flDqmzOB/tsPGvRfzElvz2lzHSVWkcxRAOddM
=J/9p
-----END PGP SIGNATURE-----