I want to log access to pages in my PHP/MySQL app to implement a view count similar to the one on SO. My plan is to count the requests by unique IP addresses on each page. There about 5000 different pages with a view-count. (I know counting IPs is not exact but that is OK for my purposes.)
I see two options to do organize the database tables:
Which one is better generally and performance wise? Or am I completely on the wrong track?
5000 tables means 5000 different queries + 5000 different sets of index + 5000 different sets of data competing for space in the server's caches. Performance will most likely be abysmal.
Multiple tables storing exactly the same data structure is almost ALWAYS a bad design. If you're worried about performance, you can use MySQL's partitioning support to split the table into multiple pieces automatically, and that's done transparently to the end-user (eg. your queries).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With