Thread: Why is it not using the other processor?
Hi, My postgres is running on a dual processor. But when I run a query and look at TOP and notice only one processor is being used. And it is being used 100% (assuming only 1 process is active). Why would it allocate the work to the other processor. Am I missing something here. If so how can I make it use the other one too? One more question. I am using the browser to display my data. If I start the query by means of pressing the Search button and then I decide to stop the search by pressing STOP (on the broswer). The browser stop executing and I can still surf the web. My question is why is the process that handles the search still running when I view TOP. It doesn't go away until it has completed it query. Is there a way I make postgres realize that netscape has terminated and it should also die. My search for example takes 10 secs. But if I stop and start it often the time it requires to search increase dramatically. I am trying to look for a solution on the postgres or apache side. Please help me.. Thanks Linh
From what I understand, postgres runs multiple 'backends' which will utilize a single process. If you have simultaneous queries running using multiple backend the backend will be distributed across your processors. If your OS doesn't support SMP that would affect it too ;) Re: killing a process from browser, I don't think what you're trying to do is really possible. If your application could be aware of the process_id of the backend (I don't know if this is possible) you could make a system call just to kill that particular backend (bad idea!) and have a client side javascript call that procedure in a hidden frame. Sounds hokey to me! I think your best bet may be to redesign your application. I don't know what kind of data you are searching against or how it is structured, but at 10 seconds to execute, and 100% CPU utilization - if you had a handful of users trying to access this data simultaneously they're going to be waiting a lot longer than 10 seconds! Good Luck! -r At 09:20 AM 7/5/01 -0600, Linh Luong wrote: >Hi, > >My postgres is running on a dual processor. But when I run a query and >look at TOP and notice only one processor is being used. And it is >being used 100% (assuming only 1 process is active). Why would it >allocate the work to the other processor. Am I missing something >here. If so how can I make it use the other one too? > >One more question. I am using the browser to display my data. If I >start the query by means of pressing the Search button and then I decide >to stop the search by pressing STOP (on the broswer). The browser stop >executing and I can still surf the web. My question is why is the >process that handles the search still running when I view TOP. It >doesn't go away until it has completed it query. Is there a way I make >postgres realize that netscape has terminated and it should also die. >My search for example takes 10 secs. But if I stop and start it often >the time it requires to search increase dramatically. I am trying to >look for a solution on the postgres or apache side. > > >Please help me.. > >Thanks > > > >Linh > >---------------------------(end of broadcast)--------------------------- >TIP 5: Have you checked our extensive FAQ? > >http://www.postgresql.org/users-lounge/docs/faq.html > > > >--- >Incoming mail is certified Virus Free. >Checked by AVG anti-virus system (http://www.grisoft.com). >Version: 6.0.251 / Virus Database: 124 - Release Date: 4/26/01 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.251 / Virus Database: 124 - Release Date: 4/26/01
Linh Luong writes: > My postgres is running on a dual processor. But when I run a query and > look at TOP and notice only one processor is being used. And it is > being used 100% (assuming only 1 process is active). Why would it > allocate the work to the other processor. Ask your operating system provider. PostgreSQL just allocates processes, it doesn't decide on what CPU they'll run. > One more question. I am using the browser to display my data. If I > start the query by means of pressing the Search button and then I decide > to stop the search by pressing STOP (on the broswer). The browser stop > executing and I can still surf the web. My question is why is the > process that handles the search still running when I view TOP. You are probably using PHP with persistent connections. They could stay open indefinitely. You might have to kill the postgres process or the web server manually. -- Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter
Doug McNaught writes: > But thre answer to his question is that a single query will use at > most 1 CPU, since each backend is a single process. Multiple > simultaneous queries will of course use all available CPUs on a > properly-setup system. It's a quality of implementation issue. An operating system could theoretically support running one process on more than one CPU, but needless to say it would be tricky. -- Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter
Peter Eisentraut <peter_e@gmx.net> writes: > Linh Luong writes: > > > My postgres is running on a dual processor. But when I run a query and > > look at TOP and notice only one processor is being used. And it is > > being used 100% (assuming only 1 process is active). Why would it > > allocate the work to the other processor. > > Ask your operating system provider. PostgreSQL just allocates processes, > it doesn't decide on what CPU they'll run. But thre answer to his question is that a single query will use at most 1 CPU, since each backend is a single process. Multiple simultaneous queries will of course use all available CPUs on a properly-setup system. -Doug -- The rain man gave me two cures; he said jump right in, The first was Texas medicine--the second was just railroad gin, And like a fool I mixed them, and it strangled up my mind, Now people just get uglier, and I got no sense of time... --Dylan
Linh Luong <linh.luong@computalog.com> wrote: > My postgres is running on a dual processor. But when I run a query and > look at TOP and notice only one processor is being used. And it is > being used 100% (assuming only 1 process is active). PostgreSQL does not use threads; there is just one backend process per session/connection. So if there is only one session connected, only one backend process will be active, and only one processor will be used. Your second processor will be used as soon as there is more than one session connected. HTH, Ray -- <GRub[B]eR> JHM, jij bent echt nerd :)) <GRub[B]eR> maar wel een goeie :) <GRub[B]eR> Soort van programmerende furby Gezien op #cistron
Ryan Mahoney <ryan@paymentalliance.net> writes: > Re: killing a process from browser, I don't think what you're trying to do > is really possible. If the client-side code were programmed to send a Cancel request to the backend when the user loses interest, then the right things would happen. I am not sure how practical that is though; does the web server even find out about it when the user presses Stop in a typical browser? (If not, you can hardly expect Postgres to somehow intuit what happened two protocols away ;-).) regards, tom lane
Tom Lane wrote: > http://thingy.kcilink.com/modperlguide/debug/Handling_the_User_pressed_Stop_.html > I am not sure how practical that is though; does the web server > even find out about it when the user presses Stop in a typical browser?
On Thu, 5 Jul 2001, Tom Lane wrote: > Ryan Mahoney <ryan@paymentalliance.net> writes: > > Re: killing a process from browser, I don't think what you're trying to do > > is really possible. > > If the client-side code were programmed to send a Cancel request to the > backend when the user loses interest, then the right things would > happen. I am not sure how practical that is though; does the web server > even find out about it when the user presses Stop in a typical browser? > (If not, you can hardly expect Postgres to somehow intuit what happened > two protocols away ;-).) Webserver definitely finds out. (Socket gets closed by client). The real question is, how does webserver signal this fact to a CGI/mod_perl/jsp/whatever web application. For CGI, _i believe_ the standard is that webserver will SIGHUP the application, and app can do whatever cleanup it needs. For other interfaces, I really don't know. -alex