Can I estimate the row count of a large mysql table using the disk space?

Let’s find an answer to "Can I estimate the row count of a large mysql table using the disk space?". The most accurate or helpful solution is served by Database Administrators.

There are ten answers to this question.

Best solution

Can I estimate the row count of a large mysql table using the disk space?

Sysadmin here (not a developer by trade), so go easy please ;) I have a mysql table, on a linux server that uses innodb_file_per_table. When I try to do select count(foo) from table; It doesn't finish. I gave it a good 5 minutes before interrupting. The table.ibd file is about 43G (45176848384). Since the count() seemed like it was never going to finish, I decided to try the following to get an estimate of the row count: I dumped the first 10,000 rows of the table and imported it to a local...

Answer:

You cannot make that kind of approximation work if the InnoDB table experiences DELETE and UPDATEs....

Read more

Kevin at Database Administrators Mark as irrelevant Undo

Other solutions

Answer:

SELECT table_name, data_length FROM information_schema.tables WHERE table_schema = [your db name] ORDER...

Read more

Adam D'Angelo at Quora Mark as irrelevant Undo

Cassandra (database): Materialized Views or Index CF, which way is better to handle 20 single column indexes to support timeline query(s) in one table?

Howdy, Can I ask a Cassandra data model question here about time series data and timeline query? Materialized Views or Index CF, which way is better to handle 20 single column indexes in one table? We have a book table with 20 columns, 300 million rows...

Answer:

Short answer - Use IndexCF. You will have to hit cassandra twice to get full object but thats a tradeoff...

Read more

Sarang Anajwala at Quora Mark as irrelevant Undo

Can a large and fast-growing InnoDB table be purged without downtime?

I have a single InnoDB table growing about 800 MB per day with user-to-user interaction data, therefore they are small inserts all day long. Today it has ~100GB of data + indicies. One day I will run out of storage in the current architecture. Most of...

Answer:

A combination of pt-archiver and pt-online-schema-change.html might accomplish what you are looking...

Read more

Aaron Brown at Quora Mark as irrelevant Undo

What is the right way to calculate the amount of disk space that the data belonging to a user takes on a shared architectured MySQL database system serving the clients of a SaaS application?

I would like to charge the users of my SaaS, by the amount of disk space that their data stored on the MySQL server is taking. There is only ione database and it's a system where all the tables contain shared data belonging to all the clients and each...

Answer:

The best way may be to rearchitect your application so that data for each client is in their own tables...

Read more

Stewart Smith at Quora Mark as irrelevant Undo

Php creating a table in mysql using a variable as table name.?

Hi, Im trying to create a table in mysql using variable $signupemail as table name. Here is my code mysql_select_db("profiles",$connect); mysql_query("CREATE TABLE ".$signupemail." (FirstName VARCHAR(30), LastName VARCHAR(30...

Answer:

its been a while since i worked with php, but it looks good to me. try setting the query as a variable...

Read more

Yang at Yahoo! Answers Mark as irrelevant Undo

Is it possible to change the schema of a MySQL table in an online fashion by using bin log replication?

I was considering following approach: Create a table with new schema in the same database Replicate all write operations of old table on this table using bin logs (Note that old table is still serving live traffic) Once new table has caught up,  rename...

Answer:

I think, your approach is correct but there might be some complications as mentioned here: pt-online...

Read more

Smit Hinsu at Quora Mark as irrelevant Undo

Creating a Table using PHP MySQL. No errors and table isn't created?

I have some code like this: $table = 'table'; $stmt = $mysqli->prepare("CREATE TABLE $table ( ... ") or die($mysqli->error); if ($stmt === FALSE) { ...show more

Answer:

Is the execute really inside the if statement as you posted it here? You have a {, but no } before ...

Read more

BFKASAW7YVN34L25NS5VPSKVTI at Yahoo! Answers Mark as irrelevant Undo

How can I update a MySql table based on another using PHP?

Using the 'product_id' in Table A, I would like to check if a product exists in Table B. If the product does exist, I want to replace the 'product_price' in Table B with the one from Table A. I am currently using a 'while' loop in PHP, checking each...

Answer:

For one I think your '$oldPrice = mysql_num_rows' line is going to cause you issues. You aren't counting...

Read more

xoroid@ymail.com at Yahoo! Answers Mark as irrelevant Undo

WordPress Plugin Development: How can I set a MySQL query to specify the options table using a user defined prefix?

I have the following line in my plugin to remove transients from the database option table. $wpdb->query( "DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient%_feed_%')" ); However, it won't work with sites which set a prefix...

Answer:

Use the global wordpress variable $table_prefix in your query: $wpdb->query( "DELETE FROM ...

Read more

Nicholas Pickering at Quora Mark as irrelevant Undo

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.