Which is faster...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Which is faster...

Post by JakeJ »

Is it faster to drop a table and recreate it or is it faster to drop all the records in the table?

The table in question will only have up to 25 records with 12 fields each.

I suppose dropping all records then optimizing table is slower than dropping an recreating an empty table.

What do best practices indicate?

Thanks!
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Which is faster...

Post by AbraCadaver »

I'm not sure. I would assume dropping the table faster, but unless you have millions or more of records I'm not sure it would be measurable and worth the time to consider. It would be easier and less code to truncate the table, and I would go that route.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
stevenrokz
Forum Newbie
Posts: 2
Joined: Thu Jan 28, 2010 5:24 am

Re: Which is faster...

Post by stevenrokz »

In table with less records dropping & recreating a table would be faster process, but dropping a table with huge data , i am not sure about
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Which is faster...

Post by pickle »

With only 25 rows, it doesn't really matter. I'd say go with whichever makes your PHP code simpler.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply