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

  • SEARCH
  • Home
  • 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 6320521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:59:15+00:00 2026-05-24T15:59:15+00:00

I’m on this machine: intel core 2 duo e8400 @3GHZ 4GB ram ddr2 php

  • 0

I’m on this machine:

intel core 2 duo e8400 @3GHZ
4GB ram ddr2

php 5.3.6
pgsql 9.1

I’m running a php script that takes like 5 minutes on a mac with similar specs.
This php script, essentially, recreate a db importing some data into it.

On this computer it runs in more than 20 minutes.

The weird thing is the use of the CPU from both PHP & POSTGRESQL

 PID  USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND 
 8408 postgres  20   0 2188m  44m  40m D    4  1.1   0:20.71 postgres                                                                                                                                          
 8407 gianps    20   0  380m 225m 6620 S    2  5.7   0:11.78 php


top - 16:08:32 up  3:35,  3 users,  load average: 1.26, 1.15, 0.80
Tasks: 187 total,   1 running, 185 sleeping,   0 stopped,   1 zombie
Cpu(s):  4.8%us,  2.7%sy,  0.2%ni, 87.0%id,  5.1%wa,  0.0%hi,  0.2%si,  0.0%st
Mem:   4056572k total,  2541972k used,  1514600k free,   117772k buffers
Swap:  3905532k total,        0k used,  3905532k free,   902048k cached

I setup the php (both cli and apache) to use as much ram as they need (memory limit -1) and tuned postgres to use:

shared_buffers = 2GB
effective_cache_size = 3072MB

Any suggestion to let this script use more ram & more cpu and run faster?

thanks

update:
after some investigation i found that that setting synchronous commit (in this situation) makes my script 10x faster.

set synchronous_commit to off;

since is not safe to make this option a default, i just switch it to off when needed..
to understand what synchronous commit does documentation

  • 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-05-24T15:59:16+00:00Added an answer on May 24, 2026 at 3:59 pm

    Importing data requires writing it to disk, so the duration of the process is likely given by the performance of the local storage system. If your Mac has a flashy SSD and the other box an IDE disk, the latter may easily be a lot slower. Use iostat to visualize disk throughput on both systems.

    Another big performance factor for inserting/writing data is commit size, try inserting a lot of rows at once and then issue a commit only every few thousand rows. Or use the even faster “COPY FROM STDIN” method (this is proprietary to Postgresql).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.