4 ms·
This really shouldn't be necessary at all. In a well-designed application, the table schema should be completely known to the application at all times -- the ex
by duskwuff 17y ago
This really shouldn't be necessary at all. In a well-designed application, the table schema should be completely known to the application at all times -- the existence of a table should never be in doubt. If for some reason this isn't the case, you'll be much better served by catching "table doesn't exist" errors when they occur rather than preemptively trying to create tables which already exist.
- NathanKP 17y agoI considered this aspect but I'm using these tables for statistics. Basically I am giving each user of my website a table for storing statistics about their site usage. Some users however, never really "complete" the process and don't really use the website, thus they have no need for statistic tables. So I have the idea of saving space by creating statistic tables as they are needed. I'm going to try the "create if not exists" first and if that causes too much MySQL server load I'll just create the statistic tables at user registration and save processor usage at the expense of disk usage.
- duskwuff 17y agoDon't create tables per user. Seriously, don't. There's a (relatively low) limit to how many tables MySQL will keep in memory, and once you hit that limit it isn't very good at keeping the right tables loaded. Instead, redesign your database schema so that you can put all of your users' data in the same tables.