Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Performance with too many databases and DbAdapter

Hi guys,

In my application, I use "The ORM also provides Horizontal Sharding facilities" with Mysql http://docs.phalconphp.com/en/latest/reference/models.html#setting-multiple-databases

public function selectReadConnection($intermediate, $bindParams, $bindTypes)

But, If I have 100 databases then I must create 100 DBAdapter (Phalcon\Db\Adapter\Pdo\Mysql) in service

$db = new DbAdapter(array("host" => $a['host'], "port" => $a['port'], "username" => $a['username'], "password" => $a['password'], "dbname" => $a['dbname'],

$di[xxx] = $db

So, How about performance in this case ? Do you have any idea for me? Please help... Thank you

100 databases! Sounds like you need to re-think your design.

Theoretically connecting to 100 databases shouldn't cause any problems other than the memory requirements to maintain 100 database connections.

edited Dec '14

100 databases! Sounds like you need to re-think your design.

Theoretically connecting to 100 databases shouldn't cause any problems other than the memory requirements to maintain 100 database connections.

Thank you

My system have many many users in the furture. Million people and more than

Please suggest me any solution to design system in this case. I also think about the vertical sharding, but I worry about insert/select or join data.

I think that Phalcon have to support for this case perfectly. But I dont know how to :(

Please help me!!!



50.6k
Accepted
answer

1,000,000 people don't require 100 separate databases. You should be able to combine all the information into one database. Breaking the information up into multiple databases doesn't give you any performance benefit. Tables is what will give you a performance benefit. Do some research into "database normalization"

1,000,000 people don't require 100 separate databases. You should be able to combine all the information into one database. Breaking the information up into multiple databases doesn't give you any performance benefit. Tables is what will give you a performance benefit. Do some research into "database normalization"

Thank you