psql half a second to start?

PostgreSQL is the database server used to store information. Do you have a question or are you having problem with PostgreSQL? If so, post them here.

Moderator: Moderators

psql half a second to start?

Postby skyd1v3r » Tue Aug 11, 2009 6:46 pm

Hello,

While this is not a concern of PT, you might have the knowledge about this:
When I start a query like psql -Upostgres -dMyBase -c"SELECT 2+2;", it takes 270 ms.
On the other hand, something like psql -Upostgres -dMyBase -c"SELECT avg(cnt_hands) FROM holdem_cache;" takes only about 280 ms. So basicly there is a period of about 269ms to start up psql.exe without accepting any query. Do you have a clue where that delay originates from, and most importantly, how I can avoid it? I´m running things inside a loop, so the 270ms DOES matter.

Thanks
skyd1v3r
 
Posts: 55
Joined: Wed Jun 10, 2009 8:24 pm

Re: psql half a second to start?

Postby WhiteRider » Wed Aug 12, 2009 5:47 am

Where does 269ms come from?
You quote 270ms in the first query and 280 for the second?
WhiteRider
Moderator
 
Posts: 54018
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: psql half a second to start?

Postby skyd1v3r » Wed Aug 12, 2009 6:51 am

ax+b ;)
when calculating the average of hundreds of thousands of lines takes 10ms longer than ading 2+2, then 2+2 will hardly take longer than a single ms. So I guess the b, the time to startup, to be 270-1= 269ms.
skyd1v3r
 
Posts: 55
Joined: Wed Jun 10, 2009 8:24 pm

Re: psql half a second to start?

Postby kraada » Wed Aug 12, 2009 9:44 am

You'd probably be better off writing a file with all of the commands you need and using psql with the -f flag - which uses a specific input file of commands.

Then you only need to call psql once.
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: psql half a second to start?

Postby skyd1v3r » Wed Aug 12, 2009 9:48 am

THat´s my current approach, yet it has the down that I get the results at the end of the progress - not allowing me to manipulate the query depending on former results.
skyd1v3r
 
Posts: 55
Joined: Wed Jun 10, 2009 8:24 pm

Re: psql half a second to start?

Postby kraada » Wed Aug 12, 2009 9:58 am

Have you tried employing another language as a wrapper? I've had success with PHP in the past.
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: psql half a second to start?

Postby skyd1v3r » Wed Aug 12, 2009 10:04 am

kraada wrote:Have you tried employing another language as a wrapper? I've had success with PHP in the past.


Isn´t wrapper something to eat? :oops:
Would love some details.
skyd1v3r
 
Posts: 55
Joined: Wed Jun 10, 2009 8:24 pm

Re: psql half a second to start?

Postby kraada » Wed Aug 12, 2009 10:09 am

This is more general, and this will become more and more useful the more you get into things.

Basically the biggest overview picture would be to use the PHP modules to call PostgreSQL queries in a single PHP script, then just put it all in HTML and you even get nicely formatted output in your browser which, if you so desire, you can even program to be interactive . . .

Warning: this sort of stuff can get addicting. Don't forget to eat! ;)
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: psql half a second to start?

Postby skyd1v3r » Wed Aug 12, 2009 10:12 am

Thanks a lot!
skyd1v3r
 
Posts: 55
Joined: Wed Jun 10, 2009 8:24 pm


Return to PostgreSQL [Read Only]

Who is online

Users browsing this forum: No registered users and 44 guests

cron