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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:56:34+00:00 2026-06-13T18:56:34+00:00

I got 2 Models, Main Model and Details Model. In my Home Controller i

  • 0

I got 2 Models, Main Model and Details Model.
In my Home Controller i want to insert 1.000.000 entries into the database, just for testing issues.

But this is very slow, the inserts are happening very slow.. is it possible to speed this up?

Maybe i did something wrong with the configuration?
Because i want, every time a Main entry is saved, a corresponding detail entry should be created.

Main Model looks like:

class Main < ActiveRecord::Base
  has_one :detail, :dependent => :destroy
  before_create :build_a_detail

private
  def build_a_detail
       self.build_detail(:Bezeichnung => 'test', :Koordinaten => 10, :main_id => self.id)
  end
end

Detail Model looks like:

class Detail < ActiveRecord::Base
  belongs_to :main
end

Home Controller:

def new
    for i in 0..1000000
      main = Main.new(:Category => 'Krankenhaus', :Latitude => 5, :Longitude => 6)
      main.save
    end
  end
  • 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-13T18:56:35+00:00Added an answer on June 13, 2026 at 6:56 pm

    The problem is that a single insert query is executed into the DB for every create and that slows the application.
    You can have bulk inserts with Rails too:
    Bulk insert in RAILS

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

Sidebar

Related Questions

I got a main table and a bezirk table. When i insert data into
I've got a set of models that look like this: class Page(models.Model): title =
I got a problem loading a second model handling a database with a module.
I've got a model like this: class Thing(models.Model): property1 = models.IntegerField() property2 = models.IntegerField()
I have a table called concept-relation and I want to insert into it. for
I've got a WPF application where PageItems are model objects. My main ViewModel has
I've got a main View Controller that has a subview of UIScrollView and another
I have got a view with search options to filter results: @model GWeb.Models.FilterModel @using
I got two models which are related via ForeignKey in Django. (I am using
I have got two models, User and Event. I need two kind of relationship

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.