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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:26:25+00:00 2026-05-11T19:26:25+00:00

I have a PHP CLI script, that processes a csv file, inserting it’s content

  • 0

I have a PHP CLI script, that processes a csv file, inserting it’s content to a table in Postgresql database. This is on an Ubuntu server. I use schedtool to control the affinity of the whole script. Schedtool is used to launch the script itself with the -e option. Unfortunately with htop I see that the database thread is spawned as a completely different thread and being not affected by the affinity options.

Is it possible to somehow make the database process inherit all affinity options from the spawner PHP script?


I have just found the answer -as I was reading some Postgresql example files for Ruby :).

My best choice would be to get the very exact PID of the Postgresql thread that is running the current script, with NOTIFY – LISTEN.
As [depesz] told Postgres uses only 1 core. With schedtool I still can control on which core it runs and with cpulimit I can control it further.

  • 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-11T19:26:25+00:00Added an answer on May 11, 2026 at 7:26 pm

    Postgres doesn’t use threads. Each connection is handled by a single threaded process. So, a single connection can only use one core. Though the OS may move it to different cores, it will only use one at a time.

    If you insist on nicing postgres, “SELECT pg_backend_pid()” will give you the PID of the postgres process without any NOTIFY/LISTEN stuff. Though, in general, you don’t want to try to nice a postgres process. You may cause other higher priority processes to block. Then what you thought was a low priority process isn’t so low-priority any more.

    If you’re just doing a bunch of inserts from a csv, nicing your script probably won’t help much. Postgres is probably doing more of the work, and it’s probably IO, so again, nicing may not get you much. You could, however, sleep every once in a while. Insert for 50 milliseconds, sleep for a while, …

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

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running on OS 3.0? I saw the same… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper,… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) -- Friday SELECT DATEPART(dw,GETDATE())… May 12, 2026 at 1:19 am

Related Questions

I have a PHP CLI script, that processes a csv file, inserting it's content
I've got a PHP script which I'm running from a command line (windows) that
I have a Linux server with multiple ips (so, multiple eth0, eth0:0, eth0:1 etc).
I'm trying to determine the best way of having a PHP script determine which
I'm writing an automation script on a production server that, among other things, needs

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.