Web Page Templates Icons, Clipart, Logos

Blog

Hot Topics

Post Archive

Tags

May 02, 2013 10:45 AM EDT

SSD vs. HDD

Solid State Drives or SSDs are one of the biggest advancements to modern computing in recent years. 

Traditional hard disk drives or HDDs consist of a series of metal platters that spin around.  There are magnetic arms that then move around to read the data off of the hard drive.  This limits the speed of the hard drive to how fast those platters can spin, and because there are moving parts involved, the hard drive tends to wear out faster than any other part of the computer.  Spinning the platters also causes additional heat and noise inside the computer.

SSDs don't have moving parts.  You can think of them as basically memory or RAM that stores the data permanently.  There are differences, of course, between these two technologies, but the high level concept is the same.

Because there are no moving parts, it is much faster to read/write data.  They also use less power and create less heat. While they'll still wear out eventually, they can last longer than traditional hard drives.

The only downside, currently, is that solid state drives cost more per GB of storage.  As the technology advances, this is becoming less of a discrepancy.  The 128GB SSD cost me $150, but you can currently get a 2TB hard drive for about $100. 

How fast is an SSD vs. an HDD

The best way to explain the difference is to give you an example.  For those of you who know MySQL, you know that backing up the database consists of running MySQLDump, which writes out a file with all the insert statements that can then be read back into MySQL to recreate a database.

I used a database that is large enough to easily see the differences.  The database dump file was about 1.5GB in size. It contains 200+ tables and millions of rows of data.

First, I restored it to my traditional hard drive, then I installed an SSD, reconfigured MySQL to use the SSD as the data directory, and then restored the same file again. The rest of the PC was exactly the same, which happens to have 4GB of RAM and a 6 core AMD Phenom II 1090T Processor.  It's running Linux Fedora 14.

This computer only has SATA2 controllers, which has a limit of 3GB/s of data that can transfer across its wires.  There are now motherboards with SATA3 controllers, which increases this limit to 6GB/s. The SSD I used was a OCZ Technology 128GB Vertex 4 Series SATA 6.0 GB/s 2.5-Inch Solid State Drive.  It's backwards compatible to the SATA2 or 3.0 GB/s speed.

My traditional hard drive took 35 minutes to import.  My solid state drive took about 5.  In theory, if I had a SATA3 controller, this could be cut in half again, though I doubt it would end up that efficient.  More likely, it would be 3 1/2 to 4 minutes.  So for this one test, the SSD was 7 times faster than my regular hard drive, and might end up 10-12 times faster under SATA3. 

There are also SATA3 controller cards that you can buy for about $50.  I thought about buying one of these, but I suspect that it wouldn't give you a full 6 GB/s because I believe you'll lose some speed as it travels through the card into the motherboard.  If you've done this, please comment and let me know your findings.

When to use SSDs

Any time you need speed over raw storage, use a SSD.  Some common uses are:

  • Boot drive - you'll boot up much faster using an SSD.  Store your photos and data on a traditional HDD.
  • Database Drive - if you are running any sort of database, the hard drive is often your slowest part.  Move your data over to a SSD and you'll notice a speed increase.
  • "Working Drive" - if you're using programs such as Photoshop that saves a history of each file change, you should see an increase in performance if your working drive is an SSD especially since most Photoshop files are 100MB or more. 
  • "Swap File" - If you are using more programs than you have available RAM, some of your working data will be moved to a file called the Swap file.  Put this on your SSD for a boost in speed.
  • Any time you're using a program that is hard drive intensive (i.e. has to load or save a lot of files or data while using the program).
  • If heat is an issue, such as in a data center where you have hundreds of computers or in a server where you're striping many hard drives together, use an SSD to decrease the amount of heat produced.
  • Use a SSD to reduce the amount of noise produced by your computer.

When to use HDDs

  • When cost is a factor
  • For raw storage such as large photos and other data that doesn't need to be accessed often
  • Storing backups where speed isn't an issue

 

 

Brian technology | computers | database | mysql | linux | data backup
Aug 04, 2009 01:13 AM EDT

PHP script to repair all MySQL databases and tables on a server

The repair table command in MySQL is useful to repair database indicies when they become corrupt. A prime example of when an index can become corrupt is when the power is shut off unexpectedly to a server. If the power is shut off after a row has been inserted into the table, but before its index has been updated, the table will become corrupt and unusable.

Unfortunately, there isn’t a “repair all tables” option that I know of. Instead, you can use this simple PHP script to do the trick for you. It simply calls “show databases” to loop through a list of your databases, and then “show tables” so that it knows which tables exist for the repair command. Depending on how many databases you have and the size of their tables, this can take several minutes to run.


<?
### Enter your username and password into the connection string: ###
$dbLink = mysql_connect("localhost", "username", "password") or die("Unable to connect to the database.");

$sql = "show databases";
$query = mysql_query($sql) or die("error fetching database names");

while ($rs=mysql_fetch_array($query)) {

//echo "Database: " . $rs['Database'] . "\n";

mysql_select_db($rs['Database'],$dbLink) or die("Unable to select database: " . $rs['Database']);

$sql = "show tables";
$query2 = mysql_query($sql) or die("error fetching table names");

while ($rs2=mysql_fetch_array($query2)) {
$key = "Tables_in_" . $rs['Database'];
//echo "Table: " . $rs2[$key] . "\n";

$sql = "repair table " . $rs2[$key];
$query3 = mysql_query($sql) or die("Error repairing a table - $sql");
$rs3 = mysql_fetch_array($query3);
echo $rs3['Table'] . " | " . $rs3['Op'] . " | " . $rs3['Msg_type'] . " | " . $rs3['Msg_text'] . "\n";

}

}

echo "Finished!\n";

?>
 

Darren mysql | database | tables | server
Aug 04, 2009 12:46 AM EDT

Upgrading Invision Powerboard 1.2 and 1.3 to use PHP5 and MySQL5

Invision Powerboard 1.2 and 1.3 are still used by many people because they’re free, where the newest versions are not. However, the coding for them isn’t 100% compatible with the latest versions of PHP and MySQL. Many web hosting companies are moving to PHP5 and MySQL5, and this will break the default installation of IPB. Here is a collection of the changes you’ll need to make to your files so that IPB 1.2 or 1.3 will work with PHP5 & MySQL 4.1 or greater.

If your forum is experiencing any of these issues, the rest of this article may fix your problem. Make sure you back up your files and database before making any changes, just in case.

Symptoms:

Blank ‘Profile’ page
Blank ‘My Controls’ page
MySQL errors when reporting post
MySQL errors on ‘The Moderating Team’ page

Files affected:

sources/misc/contact_member.php
sources/Profile.php
sources/Usercp.php
sources/misc/stats.php

Step 1:
Open sources/Usercp.php

Find:

var $parser;

Change To:

//var $parser;

Save and upload sources/Usercp.php

Step 2:
Open sources/Profile.php

Find:
var $parser;

Change To:
//var $parser;

Save and upload sources/Profile.php

Step 3:
Open sources/misc/contact_member.php
Find:

var $email = “”;
var $forum = “”;
var $email = “”;

Change To:

//var $email = “”;
var $forum = “”;
var $email = “”;

Find:

$DB->query(”SELECT m.name, m.email, mod.member_id FROM gallerymoderators mod, gallerymembers m WHERE mod.forum_id=’$fid’ and mod.member_id=m.id”);

Change To:

$DB->query(”SELECT m.name, m.email, moder.member_id FROM gallerymoderators moder, gallerymembers m WHERE moder.forum_id=’$fid’ and moder.member_id=m.id”);

Save and upload sources/misc/contact_member.php

Step 4:
Open sources/misc/stats.php
Find:

//——————————————–
// Do we have any moderators? NORMAL MODS 1st
//——————————————–

$DB->query(”SELECT m2.id, m2.name, m2.email, m2.hide_email, m2.location, m2.aim_name, m2.icq_number,
f.id as forum_id, f.read_perms, f.name as forum_name, c.state
FROM gallerymoderators mod
LEFT JOIN galleryforums f ON(f.id=mod.forum_id)
LEFT JOIN gallerycategories c ON(c.id=f.category AND c.state != 0)
LEFT JOIN gallerymembers m2 ON (mod.member_id=m2.id)
“);

Change To:

//——————————————–
// Do we have any moderators? NORMAL MODS 1st
//——————————————–

$DB->query(”SELECT m2.id, m2.name, m2.email, m2.hide_email, m2.location, m2.aim_name, m2.icq_number,
f.id as forum_id, f.read_perms, f.name as forum_name, c.state
FROM gallerymoderators moder
LEFT JOIN galleryforums f ON(f.id=moder.forum_id)
LEFT JOIN gallerycategories c ON(c.id=f.category AND c.state != 0)
LEFT JOIN gallerymembers m2 ON (moder.member_id=m2.id)
“);

Find: (this edit isn’t in 1.2, so you should be able to skip this step if that’s your version)

//——————————————–
// Do we have any moderators? GROUP MODS 1st
//——————————————–

$DB->query(”SELECT m.id, m.name, m.email, m.hide_email, m.location, m.aim_name, m.icq_number,
f.id as forum_id, f.read_perms, f.name as forum_name, c.state
FROM gallerymoderators mod
LEFT JOIN galleryforums f ON(f.id=mod.forum_id)
LEFT JOIN gallerycategories c ON(c.id=f.category AND c.state != 0)
LEFT JOIN gallerymembers m ON ((mod.is_group=1 and mod.group_id=m.mgroup))
“);

Change To:

//——————————————–
// Do we have any moderators? GROUP MODS 1st
//——————————————–

$DB->query(”SELECT m.id, m.name, m.email, m.hide_email, m.location, m.aim_name, m.icq_number,
f.id as forum_id, f.read_perms, f.name as forum_name, c.state
FROM gallerymoderators moder
LEFT JOIN galleryforums f ON(f.id=moder.forum_id)
LEFT JOIN gallerycategories c ON(c.id=f.category AND c.state != 0)
LEFT JOIN gallerymembers m ON ((moder.is_group=1 and moder.group_id=m.mgroup))
“);

Save and upload sources/misc/stats.php

Step 5:
Add the following code to the top of index.php and admin.php:

//– mod_php5 begin
$HTTP_SERVER_VARS = isset($_SERVER)?$_SERVER:array();
$HTTP_GET_VARS = isset($_GET)?$_GET:array();
$HTTP_POST_VARS = isset($_POST)?$_POST:array();
$HTTP_POST_FILES = isset($_FILES)?$_FILES:array();
$HTTP_COOKIE_VARS = isset($_COOKIE)?$_COOKIE:array();
$HTTP_ENV_VARS = isset($_ENV)?$_ENV:array();
$HTTP_SESSION_VARS = isset($_SESSION)?$_SESSION:array();
//– mod_php5 end

———

Portions of this article was paraphrased from a post by FuSoYa at http://forums.invisionize.com/index.php?showtopic=73882

Darren invision powerboard | php | mysql | database | compatibility
Aug 04, 2009 12:30 AM EDT

X-cart 4.1 multiple monthly payments module

This is more of a set of modifications rather than an actual module, but the end result is the same.

First thing you’ll need to do is backup your existing site and database. I’d recommend using a test install of Xcart so that nothing in production gets messed up. With that in mind, the first step is to alter the pricing table by using the following alter table command. If you have a different version of MySQL, you might need to tweak this a bit.

ALTER TABLE `xcart_pricing` ADD COLUMN `numpymnts` INTEGER UNSIGNED NOT NULL DEFAULT 1,
ADD COLUMN `paymentprice` DECIMAL(12,2) NOT NULL DEFAULT 0 AFTER `numpymnts`,
ADD COLUMN `sourceproductcode` VARCHAR(255) DEFAULT 0 AFTER `paymentprice`,
ADD COLUMN `sortby` INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER `sourceproductcode`,
ADD COLUMN `mastervariant` SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0 AFTER `sortby`,
ADD COLUMN `price_override` SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0 AFTER `mastervariant`,
ADD INDEX `numpymnts`(`numpymnts`),
ADD INDEX `paymentprice`(`paymentprice`),
ADD INDEX `sortby`(`sortby`),
ADD INDEX `sourceproductcode`(`sourceproductcode`),
ADD INDEX `mastervariant`(`mastervariant`),
ADD INDEX `price_override`(`price_override`)
, ENGINE = MyISAM;

The new columns are as follows:
numpyments = number of payments
paymentprice = price the export expects to see (might be one payment or the total)
sourceproductcode = product code (sku) that export expects to see
sortby = the order in which the variants show up on the admin page
mastervariant = overrides the ’starting at’ price
price_override = use this table for the price instead of the orders table for reporting

Next, you’ll need to modify some of the admin template files, such as:

Modify Files:
/skin1/modules/Product_Options/product_variants.tpl - add fields to the variants html table - don’t add the price_override column.

/modules/Product_Options/func.php - edit func_get_product_variants and add in the columns that were added to the product_variants.tpl file

When you submit the variants, the form goes to:

product_modify.php
section=variants
mode = product_variants_modify
productid = [variable]
submode = “data”
geid = “”

Once sumbitted, the code is run in this ELSEIF block in modules/Product_Options/product_variants.php:
} elseif ($mode == ‘product_variants_modify’ && $vs && $submode != ‘prices’) {

In here, you need to edit the $query_price_data array to include the additional fields; for example:

## BB Edit - added additional fields
$query_price_data = array(
"price" => $v['price'],
"variantid" => $k,
"productid" => $productid,
"quantity" => 1,
"membershipid" => 0,
"numpymnts" => $v['numpymnts'],
"paymentprice" => $v['paymentprice'],
"sortby" => $v['sortby'],
"sourceproductcode" => $v['sourceproductcode'],
"mastervariant" => $v['mastervariant']
);

Next, you need to edit the modify options page, otherwise, if you change options, it’ll remove your new field data.

When submitting this form, it passes these variables to product_modify.php:

section=options
mode=product_options_add
classid= your classid
productid = your productid
geid=”"

If you change add[is_modifier] (price modifier = ‘y’, else it’s blank), it rebuilds the variants by calling func_rebuild_variants in modules/Product_Options/func.php

//Rebuild variants: . . . . product_modify.php?productid=18&section=options&classid=71

In func_rebuild_variants, change the $_product[’prices’] $data variable to:

$data = array(
"productid" => $productid,
"quantity" => $p['quantity'],
"membershipid" => $p['membershipid'],
"variantid" => $variantid,
"price" => $p['price'],
"numpymnts" => $p['numpymnts'],
"paymentprice" => $p['paymentprice'],
"sortby" => $p['sortby'],
"sourceproductcode" => $p['sourceproductcode'],
"mastervariant" => $p['mastervariant']
);

This will keep your data from being lost in the new columns. And that’s it, as far as back end functionality for the multi pay option. Depending on how your templates are set up, you’ll probably want to use the new columns to force the “mastervariant” column to show up in the “starting at” price. Do this by ordering that query by mastervariant in descending order. The rest of the columns really come in handy when you need to see the full price such as in reports, modifying omniture code, and to produce export files where the fulfillment company wants to see the full amount instead of the per payment price.

Darren xcart | data backup | database | mysql | ecommerce
Displaying all 4 posts

Online Information for Geeks

 

 

 

 

Resource Links