Hey,
Quickie for you, in an app, picture a HUGE table that contains parameter values for subscribers, where each subscriber might have 3,000 parameters associated to them, so we’d have a table like
CREATE TABLE my_large_table (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
param_id BIGINT NOT NULL,
pvalue VARCHAR(64000) DEFAULT NULL,
ptype_id BIGINT NOT NULL DEFAULT ‘unknown’,
paccess VARCHAR(64000) DEFAULT NULL,
subscriberid BIGINT NOT NULL,
INDEX idx_subscriberid ( subscriberid )
)
AUTO_INCREMENT = 1
ENGINE = MyISAM
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_bin;
We could have eg. 100,000 - 1,000,000,000 subscribers
Now … this is MyISAM and as it is, does not suit do to if you have 30,000 subscribers logging in and updating parameters, MyISAM will lock the table on every update/insert blocking others. Everything crawls
Ok … there are 2 solutions, I know the one I’d back, but due to some guy here in work just thinking the other solution is cool or something, we’re going with it… I’d just like to get peoples opinion
Solution 1: Change the table to InnoDB so enable row locking and get rid of the problem with multiple subscribers updating their parameters (not sure if it could be partitioned based on subscriberid, think I looked at this and was shot down due to it not being unique in the table)
Solution 2: Split the table up into thousands ( 100,000 - 1,000,000,000 ) of smaller tables, so it works out 1 per subscriber, it’s still MyISAM but table locking isn’t an issue anymore
IMHO it has to be 1,
Solution 2 isn’t very very very VERY VERY VERY bad, but if you want to do any queries that involve multiple subscribers, you’re screwed. Imagine having to find all subscribers with a particular parameter value! Still, it solves the immediate problem, its just very short sighted. Mysql will handle a database with millions of tables and if all you do is get 1 subscribers details, update them, read 1 etc. its fine
Is there a limit on the number of tables you can throw into a union? Also, the number of tables would be dynamic, a new subscriber comes along, its a new table… how can you write a query to do union an ever changing number of tables!
I’d be very interested in others opinions… I don’t want to colour peoples, so please look at this with an open mind
Bal