Database partition - Better done by PHP or MySQL? -


let me explain context first : building visit tracker, php , mysql. when user visit url, informations registered, redirected page. then, when click on link, register information redirect user destination.

so need write informations in database @ moment of visit. , need read , write informations @ moment of click.

my problem have many many rows save in database. , since need read , write (so user redirected fast possible, that's main concern), thinking partitioning tables.

but fastest way of doing ? thinking 2 solutions :

partitioning table mysql

basically doing partition on table, based on range of id registered. when query data, mysql take care of directly, , transparent php side.

but since don't know how many rows have register, how can efficiently define range ? , when reach limit of partitions ?

creating new tables when needed

if have actual number of rows cached in memory, can know every 100.000 rows, need create new table. little before reach limit, have create new table. , given id, have divide 100.000 know table need query.

this way, not have problems maximum number of partitions.

but efficient in situation ? can partition system based on php (that's intend in solution #2) more efficient 1 mysql ? or should rely on mysql , if ever reach limit, create partitioned table ?


Comments