Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8678053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:36:50+00:00 2026-06-12T20:36:50+00:00

The script I’m working on is designed to update a database table which records

  • 0

The script I’m working on is designed to update a database table which records the country of use and the status of all IP addresses (or almost all of them). Currently I’m keeping it simple and am only fetching data from the 5 RIRs (Regional Internet Registries) and saving that to my database.

Initially the speeds were impractical but they have been improved signficantly by reducing the amount of information in the log and grouping the SQL inserts into groups of 1000 and using a single query. However, when running the script now I get very large variations in the speed of the SQL inserts and I was wondering if anyone knew why.

Here are the some of the speeds I’ve recorded. In the test I separated out the time taken to execute the iterations of the script in PHP and the time taken to apply the sql statement, I’ve not included the PHP times in the list below as the effect was negligible; no more than 1 second for even the largest blocks of data.

Test Speeds (number of data rows being inserted remains the same throughout)

Test 1
Total SQL executing time: 33 seconds

Test 2
Total SQL executing time: 72 seconds

Test 3
Total SQL executing time: 78 seconds

Other tests continued to fluctuate between ~30 seconds and ~80 seconds.

I have two questions:

1) Should I accept these disparities as the way of the world, or is there a reason for them?

2) I felt nervous about lumping the ~185000 row inserts into one query. Is there any reason I should avoid using one query for these inserts? I’ve not worked with this amount of data being saved at one time before.

Thank you

__

The database table is as follows.

Sorage Engine – InnoDB

Columns:

id – int, primary key

registry – varchar(7)

code – varchar(2)

type – varchar(4)

start – varchar(15)

value – int

date – datetime

status – varchar(10)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:36:51+00:00Added an answer on June 12, 2026 at 8:36 pm
    1) Should I accept these disparities as the way of the world, or is there a reason for them?
    

    Variations in speed may be due to competing processes using the disk-IO – so waiting for resources. If this is a production server not a lonely testing server then certainly some other processes are requesting access to the disk.

    2) I felt nervous about lumping the ~185000 row inserts into one query. Is there any reason I should avoid using one query for these inserts? I've not worked with this amount of data being saved at one time before.
    

    You should also divide the inserts into groups of X inserts, and insert each group as a transaction.

    Determining the value of X some other way except experimentally is hard.

    Grouping inserts into transactions ensures data is written (committed) to disk only after each transaction not after each (auto committed) insert.

    This has a good effect on disk-IO and if you group to many inserts into one transaction it can have a bad effect on available memory. If the amount of uncommitted data is too big for current memory the DBMS will start writing the data to an internal log (on disk).

    So X depends on the number of inserts, the amount of data associated with each insert, the allowed memory/user/session parameters. And many other things.


    There are some cool (free) tools from percona. They help you monitor DB activity.

    You can also look at vmstat
    watch -n .5 ‘vmstat’

    See the amount and variation of data being written to disk by the activities of the production environment.

    Start your script up and wait until you notice a step up in the number of bytes being written to disk. If writing the step up is pretty much a constant value (above the normal production use) then it’s thrashing & swapping, if it’s rhythmical then it’s only writing for commits.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following Script isn't working in CHROME browser, IE is Fine. I've changed opener.document ...
This script saves the files as /home/name/main/all my files and stuff . I want
My script works seemed to be working perfectly well, but Eclipse 3.7.2 was telling
This script has been working on 10.7 and older, but in 10.8, it seems
Script below is not working. Not getting any php error messages. Had asked a
This script works fine in all other browsers except IE: nav.addEventListener('mouseover',function(e) { switch(e.target.id) {
The script below is showing me a list of all my shops and it's
I have an autohotkey script which looks up a word in a bilingual dictionary
Script which executes commands in infinite loop in background <SOMETHING ELSE AT START OF
Script for table and sample data CREATE TABLE #TEMPTABLE1(ID INT, COL1 NVARCHAR(10)) CREATE TABLE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.