I am currently creating a tile based morpg and am trying to find a good way to store a large 2nd game world (at least 1000 squares, but hopefully more like a few thousand squares). The idea is to encourage people to create their own cities on a shared map, and users can create homes and stores so that they can be edited and have a one-to-many relationship with some related tables. I am going to send them to the client in pieces of fragments of size 64x64.
I am currently working in php / mysql, my table looks like this:
CREATE TABLE `fbmmo`.`tiles` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `x` int(11) NOT NULL, `y` int(11) NOT NULL, `realm` varchar(45) NOT NULL, `image_id` varchar(45) NOT NULL, PRIMARY KEY (`id`), KEY `Index_X` (`x`), KEY `Index_Y` (`y`) ) ENGINE=InnoDB AUTO_INCREMENT=4327236 DEFAULT CHARSET=latin1;
and queries are something like
select * from tiles where x<1000 and y<1000 and x>936 and y>936;
When I have only half a million records, it takes only half a second, but when I get about 4 million records, it takes about 5 seconds, and I'm sure this is a way to improve this.
I can get around it by caching map requests, but I wondered if there is a better way to set up the database, and also if anyone has tips on efficiently storing a large 2nd game world?
thank you for your time
source share