Re: [GENERAL] libpq ASYNC with PQgetResult and PQisBusy

2010-12-21 Thread Raimon Fernandez
hi again, On 20dic, 2010, at 18:48 , Tom Lane wrote: >> So, now I'm using the PQisBusy to check if postgre is still busy and I can >> safely call the PQgetResult wihtout blocking, or just wait *some time* >> before sending a new PQisBusy. > > Your proposed code is still a busy-wait loop. What

[GENERAL] Can the query planner create indexes?

2010-12-21 Thread Dario Beraldi
Hello, This question is just for my curiosity... When an index is available for a query, the planner decides whether to use it or not depending on whether it would make the query perform better, right? However if an index, which does not exist, would make the query run better the planner i

Re: [GENERAL] How to guard PostgreSQL from overcharged and/or malicious (read-only) queries?

2010-12-21 Thread Stefan Keller
Hi Alban Many thanks for your answers. You answered: >> 1. Filter out all SQL commands which are *not* read-only (no DROP > Most people do this using permissions. Oh, yes: forgot to mention that; that's obvious. What I also looked for was the PL/pgSQL's "EXECUTE command-string". >> 2. Get the e

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread Gabriele Bartolini
Ciao Dario, On Tue, 21 Dec 2010 09:14:36 +, Dario Beraldi wrote: the query run better the planner is not able (allowed?) to create such index, use it, and drop it once the query is done. Why is it so? Because it is not its responsibility. This is the simplest and most rational answer.

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread Massa, Harald Armin
Hello Dario, When an index is available for a query, the planner decides whether to use > it or not depending on whether it would make the query perform better, > right? However if an index, which does not exist, would make the query run > better the planner is not able (allowed?) to create such i

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread Gabriele Bartolini
Hi Harald, On Tue, 21 Dec 2010 11:42:40 +0100, "Massa, Harald Armin" wrote: a) There is a proposal (and, at the time being) also some code on pgfoundry creating "hypothetical indexes" http://postgresql.1045698.n5.nabble.com/Hypothetical-Indexes-PostgreSQL-extension-PGCON-2010-td3288085.html [

Re: [GENERAL] How to guard PostgreSQL from overcharged and/or malicious (read-only) queries?

2010-12-21 Thread Alban Hertroys
On 21 Dec 2010, at 10:57, Stefan Keller wrote: > You answered: >>> 1. Filter out all SQL commands which are *not* read-only (no DROP >> Most people do this using permissions. > > Oh, yes: forgot to mention that; that's obvious. What I also looked > for was the PL/pgSQL's "EXECUTE command-string".

[GENERAL] How to use pgbouncer

2010-12-21 Thread Adarsh Sharma
Dear all, I am not able to find any useful document regarding Configuration and Running Pgbouncer with Postgres-8.4.2. How it helps and is it able to boost some performance ? Or if there is another useful tool available for Connection Pooling. Please guide me for this. Thanks & Regards A

[GENERAL] [feature request] left/right join + limit optimization

2010-12-21 Thread pasman pasmański
hello. I think that left/right joins and limit may be optimized. When there aren't WHERE conditions this may be executed as below: Limit N Merge Left Join Sort Top N Bitmap Heap Scan ... Sort Bitmap Heap Scan ... pasman -- Sent via pgsql-general mailing li

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread Dario Beraldi
Ok, thanks a lot to all of you for your answers! (Always impressed by the prompt feedback you get on this list!) Quoting Gabriele Bartolini : Ciao Dario, On Tue, 21 Dec 2010 09:14:36 +, Dario Beraldi wrote: the query run better the planner is not able (allowed?) to create such index,

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread Jeremy Harris
On 2010-12-21 10:42, Massa, Harald Armin wrote: b) creating an index requires to read the data-to-be-indexed. So, to have an index pointing at the interesting rows for your query, the table has to be read ... which would be the perfect time to allready select the interesting rows. And after havin

[GENERAL] Trouble uninstalling old postgresql installs on osx

2010-12-21 Thread Geoff Bowers
Hi there, Have been trying to uninstall old instances of Postgres from my Snow Leopard install, preparing to install 9.0 Not sure how old these instances are (probably dates back to 7). I can see them in the active process list, but I'm not sure how to permanently stop them. Any old timers have s

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread tv
> On 2010-12-21 10:42, Massa, Harald Armin wrote: >> b) creating an index requires to read the data-to-be-indexed. So, to >> have an >> index pointing at the interesting rows for your query, the table has to >> be >> read ... which would be the perfect time to allready select the >> interesting >>

Re: [GENERAL] PostgreSQL Trusted Startup

2010-12-21 Thread Kenneth Buckler
On Mon, Dec 20, 2010 at 8:53 PM, Craig Ringer wrote: > > Do you have a trusted boot path from BIOS to bootloader to kernel to init > core userspace, where everything is digitally signed (by you or someone > else) and verified before execution? Do you disable kernel module loading? > > If not, you'

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread Grzegorz Jaśkiewicz
I don't think planner should do things like creating an index. But it might hint at doing it in the logs. There was a discussion around that sort of feature on -hackers not so long time ago. I don't remember what the conclusion was, but probably that it just isn't worth wasting planner's cycles whe

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread tv
> I don't think planner should do things like creating an index. But it > might hint at doing it in the logs. > There was a discussion around that sort of feature on -hackers not so > long time ago. I don't remember what the conclusion was, but probably > that it just isn't worth wasting planner's

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread Jeremy Harris
On 2010-12-21 14:26, t...@fuzzy.cz wrote: Why not auto-create indices for some limited period after database load (copy? any large number of inserts from a single connection?), track those that actually get re-used and remove the rest? Would this not provide a better out-of-the-box experience

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread bricklen
On Tue, Dec 21, 2010 at 7:34 AM, Jeremy Harris wrote: > On 2010-12-21 14:26, t...@fuzzy.cz wrote: >>> >>> Why not auto-create indices for some limited period after database load >>> (copy?  any large number of inserts from a single connection?), track >>> those >>> that actually get re-used and re

Re: [GENERAL] How to use pgbouncer

2010-12-21 Thread Filip Rembiałkowski
2010/12/21 Adarsh Sharma : > Dear all, > > I am not able to find any useful document regarding Configuration and > Running Pgbouncer with Postgres-8.4.2. that's strange, there are several good pages on the web; there is also my mini-howto: http://filip.rembialkowski.net/pgbouncer-mini-howto-benchm

Re: [GENERAL] How to use pgbouncer

2010-12-21 Thread Richard Broersma
2010/12/21 Filip Rembiałkowski : >> Or if there is another useful tool available for Connection Pooling. Please >> guide me for this. > > yes there are some; see > http://wiki.postgresql.org/wiki/Replication,_Clustering,_and_Connection_Pooling > > it depends on what you need. pgbouncer is the small

Re: [GENERAL] How to use pgbouncer

2010-12-21 Thread Andreas Kretschmer
Richard Broersma wrote: > 2010/12/21 Filip Rembiałkowski : > >> Or if there is another useful tool available for Connection Pooling. Please > >> guide me for this. > > > > yes there are some; see > > http://wiki.postgresql.org/wiki/Replication,_Clustering,_and_Connection_Pooling > > > > it depend

[GENERAL] Constraining overlapping date ranges

2010-12-21 Thread McGehee, Robert
PostgreSQLers, I'm hoping for some help creating a constraint/key on a table such that there are no overlapping ranges of dates for any id. Specifically: Using PostgreSQL 9.0.1, I'm creating a name-value pair table as such this: CREATE TABLE tbl (id INTEGER, start_date DATE, stop_date DATE, va

Re: [GENERAL] Constraining overlapping date ranges

2010-12-21 Thread Richard Broersma
On Tue, Dec 21, 2010 at 7:49 AM, McGehee, Robert wrote: > PostgreSQLers, > I'm hoping for some help creating a constraint/key on a table such that there > are no overlapping ranges of dates for any id. There is something you can try, but it is not exactly what you want since it is based on time

[GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Kelly Burkhart
Hello, I'm sending a group of queries to the database with PQsendQuery and using PQgetResult to return results similar to this: PQsendQuery( "select current_timestamp; select pg_sleep(1); select current_timestamp" ); while( result = PQgetResult() ) doSomethingWith( result ) I'm finding that

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread Tomas Vondra
Dne 21.12.2010 16:34, Jeremy Harris napsal(a): >> There really is no automatic way to solve this puzzle using a single >> query. Indexing strategy is a very tough design discipline, and it >> requires a complex knowledge of the workload. One slow query does not >> mean >> the index should be create

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread Jeremy Harris
On 2010-12-21 18:50, Tomas Vondra wrote: Then the index you just built gets automatically dropped, as I said above. I'm a bit confused. Should the indexes be dropped automatically (as you state here) or kept for the future. Because if they should be dropped, then it does not make sense to do th

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Peter Geoghegan
You can't concurrently execute queries from within a single connection. Perhaps you should use multiple connections, while understanding the implications of having each operate within a separate snapshot. Don't forget to free memory with PQclear() . I guess you omitted that because it's just pseud

Re: [GENERAL] Can the query planner create indexes?

2010-12-21 Thread Tomas Vondra
Dne 21.12.2010 20:03, Jeremy Harris napsal(a): > On 2010-12-21 18:50, Tomas Vondra wrote: >>> Then the index you just built gets automatically dropped, as I said >>> above. >> >> I'm a bit confused. Should the indexes be dropped automatically (as you >> state here) or kept for the future. Because i

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 2:21 PM, Peter Geoghegan wrote: > You can't concurrently execute queries from within a single > connection. Perhaps you should use multiple connections, while > understanding the implications of having each operate within a > separate snapshot. OP is not suggesting that qu

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Kelly Burkhart
Yes, I omitted the PQclear for simplicity. I'm not concurrently executing queries, I'm sending multiple queries to be executed serially by the backend. I'm expecting the server to send me the PQresult objects as each query completes rather than sending them all *after* all of the queries have com

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Kelly Burkhart
This should do it: #include #include #include #define CONNINFO "your info here" #define COMMANDS "select current_timestamp; select pg_sleep(5); select current_timestamp" void fatal( const char *msg ) { fprintf( stderr, "%s\n", msg ); exit(1); } int main() { PGresult *res = 0; PGconn

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Daniel Verite
Kelly Burkhart wrote: > #define COMMANDS "select current_timestamp; select pg_sleep(5); select > current_timestamp" You should use current_clock() instead of current_timestamp, because current_timestamp returns a fixed value throughout a transaction. Best regards, -- Daniel PostgreSQL-p

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 3:07 PM, Daniel Verite wrote: >        Kelly Burkhart wrote: > >> #define COMMANDS "select current_timestamp; select pg_sleep(5); select >> current_timestamp" > > You should use current_clock() instead of current_timestamp, because > current_timestamp returns a fixed value

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 3:14 PM, Merlin Moncure wrote: > On Tue, Dec 21, 2010 at 3:07 PM, Daniel Verite > wrote: >>        Kelly Burkhart wrote: >> >>> #define COMMANDS "select current_timestamp; select pg_sleep(5); select >>> current_timestamp" >> >> You should use current_clock() instead of cu

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 3:37 PM, Merlin Moncure wrote: > On Tue, Dec 21, 2010 at 3:14 PM, Merlin Moncure wrote: >> On Tue, Dec 21, 2010 at 3:07 PM, Daniel Verite >> wrote: >>>        Kelly Burkhart wrote: >>> #define COMMANDS "select current_timestamp; select pg_sleep(5); select curre

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 3:40 PM, Merlin Moncure wrote: > On Tue, Dec 21, 2010 at 3:37 PM, Merlin Moncure wrote: >> On Tue, Dec 21, 2010 at 3:14 PM, Merlin Moncure wrote: >>> On Tue, Dec 21, 2010 at 3:07 PM, Daniel Verite >>> wrote:        Kelly Burkhart wrote: > #define COMMANDS

Re: [GENERAL] How to use pgbouncer

2010-12-21 Thread Filip Rembiałkowski
2010/12/21 Andreas Kretschmer : > > I'm looking for a solution to split read and write access to different > servers (streaming replication, you know ...). Can i do that with > pgpool? (setting backend_weightX=0 or 1)? I have read the doc, but i'm > not sure if pgpool the right solution, maybe you

Re: [GENERAL] What Programs Do You Use For PG?

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 1:32 AM, Neil D'Souza wrote: > You can have a look at my project on sourceforge: > http://sourceforge.net/projects/proghelp builds applications with PG as a > backend automatically. It uses a modified create table sql grammar as an > input. > > 1. It automatically  generate

[GENERAL] schemaverse!

2010-12-21 Thread Merlin Moncure
A postgresql based game, that you can play from psql! Written by Abstrct (Josh) http://www.schemaverse.com/ merlin -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] schemaverse!

2010-12-21 Thread A.M.
On Dec 21, 2010, at 5:06 PM, Merlin Moncure wrote: > A postgresql based game, that you can play from psql! Written by Abstrct > (Josh) > > http://www.schemaverse.com/ Finally, a game which makes it look like I am doing work! -- Sent via pgsql-general mailing list (pgsql-general@postgresql.

Re: [GENERAL] Understanding PG9.0 streaming replication feature

2010-12-21 Thread Ben Carbery
FYI, not looking for a detailed how to here.. I have read the manual twice and just can't figure which sections are relevant. The manual seems to be trying to cover all uses simultaneously which is always going to get confusing :) For example do I need I need WAL archiving or not? On Tue, Dec 21,

[GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread TJ O'Donnell
In postgresql-9.0.1 I have to modify my plpython functions that return arrays. It seems one dimesional arrays are handled properly, but not 2-dimensional arrays. create or replace function atest() returns integer[] as $eopy$ a = list() a.append(1) a.append(2) a.append(3) #return a works fine

Re: [GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread Thom Brown
On 21 December 2010 22:48, TJ O'Donnell wrote: > In postgresql-9.0.1 I have to modify my plpython functions that return arrays. > It seems one dimesional arrays are handled properly, but not > 2-dimensional arrays. > > create or replace function atest() returns integer[] as $eopy$ >  a = list() >

Re: [GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread Peter Geoghegan
On 21 December 2010 23:17, Thom Brown wrote: > Are you sure that "a" returns okay in that scenario. You're using a > list. Shouldn't you be using an array? Like: a = [] a =[] actually declares an empty list in Python. You can return a list or a tuple from a pl/python function in 9.0 and it wil

Re: [GENERAL] Understanding PG9.0 streaming replication feature

2010-12-21 Thread Satoshi Nagayasu
Hi Ben, On 2010/12/22 7:46, Ben Carbery wrote: FYI, not looking for a detailed how to here.. I have read the manual twice and just can't figure which sections are relevant. The manual seems to be trying to cover all uses simultaneously which is always going to get confusing :) For example do

Re: [GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread Adrian Klaver
On Tuesday 21 December 2010 2:48:16 pm TJ O'Donnell wrote: > In postgresql-9.0.1 I have to modify my plpython functions that return > arrays. It seems one dimesional arrays are handled properly, but not > 2-dimensional arrays. > > create or replace function atest() returns integer[] as $eopy$ > a

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Tom Lane
Merlin Moncure writes: > hm, a pq_flush() after command completion putmessage in > backend/tcop/dest.c seems to fix the problem. I'll send up a patch to > -hackers. They might backpatch it, unless there is a good reason not > to do this (I can't think of any). If you just unconditionally flush

Re: [GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread Adrian Klaver
On Tuesday 21 December 2010 3:25:48 pm Peter Geoghegan wrote: > On 21 December 2010 23:17, Thom Brown wrote: > > Are you sure that "a" returns okay in that scenario. You're using a > > list. Shouldn't you be using an array? Like: a = [] > > a =[] actually declares an empty list in Python. You c

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Merlin Moncure
On Tue, Dec 21, 2010 at 6:49 PM, Tom Lane wrote: > Merlin Moncure writes: >> hm, a pq_flush() after command completion putmessage in >> backend/tcop/dest.c seems to fix the problem.  I'll send up a patch to >> -hackers.  They might backpatch it, unless there is a good reason not >> to do this (I

Re: [GENERAL] libpq sendQuery -- getResult not returning until all queries complete

2010-12-21 Thread Tom Lane
Merlin Moncure writes: > On Tue, Dec 21, 2010 at 6:49 PM, Tom Lane wrote: >> If you just unconditionally flush there, it will result in an extra >> network message in the normal case where there's not another query >> to do.  The current code is designed not to flush until it sends >> ReadyForQue

Re: [GENERAL] PostgreSQL Trusted Startup

2010-12-21 Thread Craig Ringer
On 12/22/2010 02:05 AM, Kenneth Buckler wrote: I find it very comforting that I am not the only one who finds this requirement a bit "out there". Unfortunately, these requirements are set in stone, and no matter how hard I try, can not be altered. We live in a world where compliance is king. Ne

Re: [GENERAL] PostgreSQL Trusted Startup

2010-12-21 Thread Craig Ringer
We live in a world where compliance is king. Nevermind if compliance doesn't actually make the system more secure. Er .. re my previous post, I don't mean "lie to RH and claim to want to buy RHEL to get free support". I mean that you should consider going to management and getting approval fo

Re: [GENERAL] Understanding PG9.0 streaming replication feature

2010-12-21 Thread Matthias Müller
Hi Ben, load balancing is not possible with the tools that are in the postgres installation. There is no automatic switch-over to a slave if the master fails. The trigger file needs to be created to make a slave to the master. This is not done automaitcally by postgres, but should be done by a

[GENERAL] Cannot unsubscribe

2010-12-21 Thread William Gordon Rutherdale (rutherw)
I attempted to unsubscribe from this list (for the holidays) without success. Could anyone please help me. I am continuing to get messages from the list. I broke open the message header and did as it said for unsubscribing. See below for what the majordomo sent back. -Will unsub pgsql-g

Re: [GENERAL] Understanding PG9.0 streaming replication feature

2010-12-21 Thread Fujii Masao
On Wed, Dec 22, 2010 at 8:31 AM, Satoshi Nagayasu wrote: > My blog entry would be a good entry point for you.  :) > > 5 steps to implement a PostgreSQL replication system > http://pgsnaga.blogspot.com/2010/05/5-steps-to-implement-postgresql.html Or http://wiki.postgresql.org/wiki/Binary_Replicati

Re: [GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread TJ O'Donnell
In previous versions (8.x) for plpython fn returning integer[] I created (had to create) a string in the proper SQL format { {1,2,3}, {4,5,6} } and returned that. It worked fine. I LIKE the ability to not have to do that in 9.0 but I CAN'T return and string like { {1,2,3}, {4,5,6} } for a fn th

[GENERAL] Database file copy

2010-12-21 Thread Srini Raghavan
Hello, We are looking to distribute postgres databases to our customers along with our application. We are currently evaluating postgres version 8.4.4. The database can be of size 25 gb (compressed files fits in few dvds, the product is distributed on dvds). The pg_restore of this database take

Re: [GENERAL] Cannot unsubscribe

2010-12-21 Thread Adrian Klaver
On Tuesday 21 December 2010 4:16:00 pm William Gordon Rutherdale (rutherw) wrote: > I attempted to unsubscribe from this list (for the holidays) without > success. > > Could anyone please help me. I am continuing to get messages from the > list. > > I broke open the message header and did as it s

[GENERAL] Table inheritance foreign key problem

2010-12-21 Thread Andy Chambers
Hi, One of the caveats described in the documentation for table inheritance is that foreign key constraints cannot cover the case where you want to check that a value is found somewhere in a table or in that table's descendants. It says there is no "good" workaround for this. What about

Re: [GENERAL] Table inheritance foreign key problem

2010-12-21 Thread Richard Broersma
On Tue, Dec 21, 2010 at 9:32 PM, Andy Chambers wrote: \ > create table guidebooks ( >  city check (city in (select name >                         from cities)), >  isbn text, >  author text, >  publisher text); This is a nice idea. They only problem is that PostggreSQL doesn't support sub-select