MYSQL Insert Is Slow

The time required for execution of inserting a row in MySQL depends on a few factors -- the connection between client and server, transferring the query to the server, parsing query, inserting rows, the size of the table, inserting indexes and closing the table. Fortunately, there are various methods to speed up the slow insertion of rows. One of these methods is to use INSERT statements with multiple VALUES lists to insert several rows at a time rather than insert one row each time. This method is much faster than the single-row INSERT statements.

Instructions

    • 1

      Log into your PHPMyAdmin as a root user. Create a new database namely "Sales" by entering a name for the database in the text box under "Create New Database."

    • 2

      Create a new table by entering a name for the table. Specify the number of fields for the table "products." Click "Go." PHPMyAdmin is user-friendly tool to manage MySQL Server.

    • 3

      Create three fields for the table "products," namely "id," "name" and "quantity." Select "varchar" data type for fields id and product. Set quantity field as "Integer" data type.

    • 4

      Click "Query" to open the query interface. Enter the following code to insert a few rows simultaneously:

      INSERT INTO products (id, name, quantity)

      VALUES

      (1, "product1", 20),

      (2, "product2", 38),

      (3, "product3", 32);

Related Searches:

References

Comments

Related Ads

Featured