How many tables does MySQL handle?

3

Well, what I want to do is create a table in my database for each user, now my question is: How many tables does MySQL handle?

Is it possible to put a lot of tables on my server that does not crash or give a bug?

My site has close to 1000 users.

What do you recommend?

Thank you.

    
asked by anonymous 04.11.2016 / 20:47

2 answers

4

According to the Mysql documentation, there is no table or database boundary. The underlying file system may have a limit on number of directories .

Engines can have an individual value, such as InnoDB that allows more than 4 billion tables.

What can occur is slow, due to the number of existing tables, but limit does not exist, depending on the storage engine.

Also note that this is a bad practice, of course, depends on the application, but I do not see any need to do this, seeing that the programming language itself with a good modeling in the DB can resolve it in a cleaner way and efficient.

See more at Limits on Number of Databases and Tables

    
04.11.2016 / 20:56
11

I do not think your premise is a good idea.

Imagine that you want to add a column in these "tables per user". 1000 users would mean at least 1000 commands to run! What a nightmare in both performance and administration.

If your goal is to separate user content, I suggest:

  • Create a 'Users' table
  • For each table to be separated, include a foreign key for the 'Users' table.

In this way, fetching a user's content would be as simple as adding a WHERE:

SELECT pedidos.valor
  FROM pedidos
 WHERE usuarioId = 10;

That's a lot easier.

    
04.11.2016 / 21:04