MySQL - How to measure the amount of space used by certain rows? -


i working on project management program, built on lamp stack. have tentatively chosen not provide each 1 of clients own database, rather combine business' data 1 large database.

the first column in database tables business_id. row indicates business piece of data belongs to, keeps exposing business 1's data business 2.

but try iron out billing kinks, useful able run cron job once month determine how database space each business using. here's question: there way mysql return number of bytes used rows business_id = 'x'?

since billing information customer explicitly paying store, sum lengths of fields explicitly give you. (omit internal fields business_id, service_level_id, permissions, or whatever.) then, refer storage requirements , calculate.

so, b number of bytes required numeric fields, , there 3 text fields txta, txtb, , txtc, instance:

select     business_id,     count(*) * b +         sum(length(txta) + length(txtb) + length(txtc)) bytes table business_id={id}; 

but, once you've got reasonable amount of data in system, suspect query going pretty long-running. might simpler tell clients you'll billing them on "approximate" data storage. use average_row_length * count(*) of rows , trim little off account overhead.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -