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 7809741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:31:59+00:00 2026-06-02T03:31:59+00:00

I have 1 function in my debug model which i want to use in

  • 0

I have 1 function in my debug model which i want to use in order to add dummy data to my app to test its speed and such…

the problem is that it needs to add records to 2 different tables and also check for duplicates usernames etc before each record is added to db so it takes a little time…

also this procedure is repeated about $total different dummy records i want to add at once in a for loop…

for example for 100 new users i want to add it takes around 5 seconds to proceed.

is this time fine or do i need to optimize it?

what if i want to add 1000,10000 users at once?? is it possible?

EDIT:
Function called to insert data:

public function registerRandomUsers($total = 1){
    $this->load->model("misc_model");
    $this->load->model("encryption_model");
    $this->load->model("signup_model");

    for ($i=1;$i<=$total;$i++){
        $username = $this->misc_model->generateRandomString(15);
        $flag = false;
        while ($flag == false){
            if ($this->user_model->usernameExist($username)){
                $username = $this->misc_model->generateRandomString(15);
            }else{
                $flag = true;

                $password = 'Test123';
                $email = $username.'@email.com';
                $data = array(
                    'username' => $username,
                    'password' => $password,
                    'email' => $email
                );
                $this->signup_model->submitRegistration($data);
                $userdata = $this->user_model->getUserData($username, "username");
            }
        }
    }
}
  • 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-02T03:32:01+00:00Added an answer on June 2, 2026 at 3:32 am

    If you’re not worried about having a random string as the user name, just set the $email = 'user'.$i.'@email.com'; (so you don’t have to worry about collisions). The main reason this will be running slow is because you’re sending a new query to the database on each iteration of the loop – it would be much much faster to generate a bulk insert string like:

    INSERT INTO user (email,pass)
    VALUES ('user1@email.com','Test123')
    ,      ('user2@email.com','Test123')
    ,      ('user3@email.com','Test123')
    ,      ('user4@email.com','Test123')
    ,      ('user5@email.com','Test123');
    

    This way you can avoid the overhead of tcp traffic from sending 10000 queries to the database and have it do it all in one go.

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

Sidebar

Related Questions

Update 2 : So I never have used the debug function in firebug, but
I've been using debug() more often now, but sometimes I wonder which functions have
I have function: char *zap(char *ar) { char pie[100] = INSERT INTO test (nazwa,
I have function getCartItems in cart.js and I want to call that function in
I have function some_func_1 which will create an object of type some_type and will
I have the following function which is being called as the start to a
I have a class called MODEL in which public static int theMaxFrames resides. The
I got an .aspx file in which I want to have a file uploader
I have a problem where I dispatch an event in a model class which
I want to call a function right after a scroll ends. I have tried

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.