Re: [GENERAL] Why DISTINCT ... DESC is slow?

2006-12-12 Thread Richard Huxton
Michael Glaesemann wrote: On Dec 12, 2006, at 16:43 , Richard Huxton wrote: Anton wrote: While without DESC query goes faster... But not so fast! =# explain analyze SELECT DISTINCT ON (login_id) login_id, collect_time AS dt FROM n_traffic ORDER BY login_id collect_time; QUERY PLAN

Re: [GENERAL] search_path when restoring to new db

2006-12-12 Thread SunWuKung
Ok, I understand this difference now. Knowing that, what is the standard way to copy a single database to another server? - can I use pg_dumpall to dump a single db? - or - I have to use pg_dump and there is a procedure to ensure that old and new dbs are the same, like 1. create new db 2. check

Re: [GENERAL] Why DISTINCT ... DESC is slow?

2006-12-12 Thread Anton
Why? 768 rows is about 1000 times smaller than entire n_traffic. And why Index Scan used without DESC but with DESC is not? For the DESC version to use the index try login_id DESC collect_time DESC - so both are reversed. Yes, it helps! But If you want the most recent collect_time for each

Re: [GENERAL] Why DISTINCT ... DESC is slow?

2006-12-12 Thread Richard Huxton
Anton wrote: SELECT login_id, MAX(collect_time) AS most_recent FROM n_traffic GROUP BY login_id ORDER BY login_id DESC, collect_time DESC is not so good: =# SELECT login_id, MAX(collect_time) AS most_recent -# FROM n_traffic -# GROUP BY login_id -# ORDER BY login_id DESC, collect_time DESC;

[GENERAL] any api in libpq to get the number of connections

2006-12-12 Thread surabhi.ahuja
Hi, is ther any api avaiable in libpq so that i can get the number of connections that exists with the database thanks, regards surabhi This message has been scanned by the Trend Micro IGSA and found to be free of known security risks

[GENERAL] returning parameters from function

2006-12-12 Thread Rikard Pavelic
Hi! Is there any plan to add implicit declaration of returning parameters for functions? Something like: create function list(in a int) returns setof implicit record as $$ if a=1 then select * from table1; else select * from table2; end if; $$ languge sql; which would than dynamically create

Re: [GENERAL] any api in libpq to get the number of connections

2006-12-12 Thread Shoaib Mir
This might be of some help using a query like: select count(*) as NumberOfConn from pg_stat_activity where datname = 'dbname'; -- Shoaib Mir EnterpriseDB (www.enterprisedb.com) On 12/12/06, surabhi.ahuja [EMAIL PROTECTED] wrote: Hi, is ther any api avaiable in libpq so that i

Re: [GENERAL] out of memory error on 3 table join

2006-12-12 Thread Martijn van Oosterhout
On Mon, Dec 11, 2006 at 05:50:53PM -0600, Kirk Wythers wrote: met_data=# SELECT count(*) FROM climate, sites, solar WHERE climate.id = sites.id AND solar.id = sites.id AND climate.year = 1999; -- 33061700 (1 row) snip psql(394) malloc: *** vm_allocate(size=396742656) failed

Re: [GENERAL] Metadata from NEW and OLD constructs?

2006-12-12 Thread Martijn van Oosterhout
On Mon, Dec 11, 2006 at 06:19:33PM -0700, Lenorovitz, Joel wrote: Greetings, I was wondering if it's possible to get any of the metadata from the NEW and OLD constructs in a trigger or view rule? Specifically, I'd like to get the column name or identifier anywhere the new record differs

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Martijn van Oosterhout
On Tue, Dec 12, 2006 at 10:30:07AM +0100, Rikard Pavelic wrote: Hi! Is there any plan to add implicit declaration of returning parameters for functions? Something like: create function list(in a int) returns setof implicit record as snip Just setof record will do. As for the implicit

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Shoaib Mir
On Tue, Dec 12, 2006 at 10:30:07AM +0100, Rikard Pavelic wrote: Hi! Is there any plan to add implicit declaration of returning parameters for functions? Something like: create function list(in a int) returns setof implicit record as You can use a SETOF function as: CREATE OR REPLACE FUNCTION

[GENERAL] server speed question

2006-12-12 Thread Tomi N/A
I'm trying to optimize performance on my development laptop, one of the main bottlenecks beeing a 4200 rpm disk. It's a fairly good machine (Pentium M, 1,73GHz, 1GB RAM), but pg doesn't seem to use the processing power: the disk works all of the time. I'm working with a database with a couple of

[GENERAL] Database Synchronization

2006-12-12 Thread Rohit Prakash Khare
I developed an app. using VB.NET and MS Access. The Access MDB has 27 tables. I want to develop the reporting module using VB.NET and PostgreSQL. I want to know whether there are any tools available that can migrate existing Access database to PostgreSQL and later synchronize changes in Access

[GENERAL] where can i find posges sql include directory...FC5.installing rpms

2006-12-12 Thread Faqeer ALI
i have installed post gres which comes with the distribution of Fedora Core 5.. but when i compiled opennms it needs to get the include directory of postgres.. error cannot find postgres.h.. Any body plz help me...

Re: [GENERAL] where can i find posges sql include directory...FC5.installing rpms

2006-12-12 Thread Shoaib Mir
You can get the include files as part of the source ( http://www.postgresql.org/ftp/source/). Shoaib Mir EnterpriseDB (www.enterprisedb.com) On 12/12/06, Faqeer ALI [EMAIL PROTECTED] wrote: i have installed post gres which comes with the distribution of Fedora Core 5.. but

Re: [GENERAL] where can i find posges sql include directory...FC5.installing

2006-12-12 Thread Richard Huxton
Faqeer ALI wrote: i have installed post gres which comes with the distribution of Fedora Core 5.. but when i compiled opennms it needs to get the include directory of postgres.. error cannot find postgres.h.. Firstly try locate postgres.h and see if that finds it. If not, you probably

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Rikard Pavelic
Shoaib Mir wrote: You can use a SETOF function as: CREATE OR REPLACE FUNCTION get_test_data (numeric) RETURNS SETOF RECORD AS $$ DECLARE temp_recRECORD; BEGIN FOR temp_rec IN (SELECT ename FROM emp WHERE sal $1) LOOP RETURN NEXT temp_rec; END LOOP; RETURN;

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Matthias . Pitzl
You have to call the function in the following form: SELECT * FROM get_test_data(1) AS (field1 type, field2 type, ...) In words, you have to tell the database how the data returned by the function has to be interpreted. Greetings, Matthias -Original Message- From: [EMAIL PROTECTED]

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Rikard Pavelic
Martijn van Oosterhout wrote: snip Just setof record will do. As for the implicit declaration of variable names, that's harder. I don't know if you can do that without making things very ambiguous. I know setof record will do if I explicitly name OUT parameters. But I want Postgre to figure

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Richard Huxton
Rikard Pavelic wrote: Martijn van Oosterhout wrote: snip Just setof record will do. As for the implicit declaration of variable names, that's harder. I don't know if you can do that without making things very ambiguous. I know setof record will do if I explicitly name OUT parameters. But I

[GENERAL] (Perl) script to set up an instance for regression tests

2006-12-12 Thread Florian Weimer
For regression tests, I'd like to automatically set up a fresh PostgreSQL instance. Has anybody automated the task (initdb, setting a password, choosing a port at random, starting the server, and after running the tests, stopping the server and deleting all the directories)? I know, it's a

Re: [GENERAL] search_path when restoring to new db

2006-12-12 Thread Brandon Aiken
The standard method is to use a pg_dumpall for the initial copy and whenever globals or the schema changes, and use pg_dump when you just want to get the data from a single database. Globals and schema should not change very often. In fact, they should be fixed except between software

[GENERAL] PostgreSQL 8.2 : IPO link warning with ICC 9.1.045

2006-12-12 Thread DANTE Alexandra
Hello List, I'm back with my questions on compilation of PostgreSQL 8.2. :-) I work with an IA-64 server with Red Hat Enterprise Linux 4 AS update 2 on which the Intel compiler icc 9.1.045 is available. I try to build PostgreSQL 8.2 with this compiler. To do that : - I generated RPM from the

Re: [GENERAL] search_path when restoring to new db

2006-12-12 Thread Richard Huxton
Brandon Aiken wrote: PostgreSQL is simply very granular about what it lets you dump. True enough, but I'd think you could make a good argument that dumping a database should dump any ALTER commands that are attached to it. Users are shared between databases, so I can see it doesn't

Re: [GENERAL] Restore database from files (not dump files)?

2006-12-12 Thread Tom Lane
wheel [EMAIL PROTECTED] writes: I guess the reason is that the pg system database etc are lodged in the hive under \base\, and the system db contains the metadata about the db to be restored? No, the reason why selective restore doesn't work is that all tables in a database cluster depend

[GENERAL] Unrecognized time zone name error.

2006-12-12 Thread Brad Nicholson
This seems odd. Any idea what's going on here? template1=# SET TimeZone TO 'GMT'; ERROR: unrecognized time zone name: GMT template1=# SELECT version(); version - PostgreSQL 8.1.5 on

Re: [GENERAL] forcing compression of text field

2006-12-12 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/11/06 10:18, Jonathan Ellis wrote: I have a table of log messages. They are mostly in the 100-200 character length, which apparently isn't large enough for PG to want to compress it (length == octet_length). I really need to save disk

Re: [GENERAL] Why DISTINCT ... DESC is slow?

2006-12-12 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/12/06 01:28, Anton wrote: Hi. With this table (about 800 000 rows): =# \d n_traffic Table public.n_traffic Column|Type | Modifiers

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Rikard Pavelic
Richard Huxton wrote: Rikard Pavelic wrote: I know setof record will do if I explicitly name OUT parameters. But I want Postgre to figure out for himself what parameters to return as out parameters. I don't see why it would make things very ambiguous. Think about what happens if you use

Re: [GENERAL] where can i find posges sql include directory...FC5.installing rpms

2006-12-12 Thread Tom Lane
Faqeer ALI [EMAIL PROTECTED] writes: i have installed post gres which comes with the distribution of Fedora Core 5.. but when i compiled opennms it needs to get the include directory of postgres.. error cannot find postgres.h.. Did you install postgresql-devel RPM? It's in there: ...

[GENERAL] PostgreSQL Developer Full-time Position

2006-12-12 Thread Andrew Chernow
Our Company: eSilo is a privately held Storage Service Provider, providing offsite backup and storage management solutions to businesses of all sizes. eSilo built its backup technology in house and continues to expand and innovate. For more information about eSilo, please visit our website:

Re: [GENERAL] (Perl) script to set up an instance for regression tests

2006-12-12 Thread Tom Lane
Florian Weimer [EMAIL PROTECTED] writes: For regression tests, I'd like to automatically set up a fresh PostgreSQL instance. Has anybody automated the task (initdb, setting a password, choosing a port at random, starting the server, and after running the tests, stopping the server and

Re: [GENERAL] returning parameters from function

2006-12-12 Thread Shoaib Mir
You can use it as: SELECT * FROM get_test_data(1000) AS t1 (emp_name VARCHAR); -- Shoaib Mir EnterpriseDB (www.enterprisedb.com) On 12/12/06, Rikard Pavelic [EMAIL PROTECTED] wrote: Shoaib Mir wrote: You can use a SETOF function as: CREATE OR REPLACE FUNCTION get_test_data

Re: [GENERAL] search_path when restoring to new db

2006-12-12 Thread Tom Lane
Richard Huxton dev@archonet.com writes: True enough, but I'd think you could make a good argument that dumping a database should dump any ALTER commands that are attached to it. Let's suppose pg_dump did that, so pg_dump foo foo.dump includes commands like ALTER DATABASE foo SET ...

[GENERAL] Running initdb from another process

2006-12-12 Thread Greg Fairbanks
Hi, I am looking at trying to integrate PostgreSQL into our software. Basically, I want to have our software to spawn postgres so the user doesn't have to concern themselves with managing the database. I am using the Windows calls LogonUser and CreateProcessAsUser to start initdb as an

Re: [GENERAL] Unrecognized time zone name error.

2006-12-12 Thread Tom Lane
Brad Nicholson [EMAIL PROTECTED] writes: This seems odd. Any idea what's going on here? template1=# SET TimeZone TO 'GMT'; ERROR: unrecognized time zone name: GMT Worksforme. Perhaps you are missing the /usr/share/pgsql/timezone/ directory (your path might vary)?

Re: [GENERAL] search_path when restoring to new db

2006-12-12 Thread Richard Huxton
Tom Lane wrote: Richard Huxton dev@archonet.com writes: True enough, but I'd think you could make a good argument that dumping a database should dump any ALTER commands that are attached to it. Let's suppose pg_dump did that, so pg_dump foo foo.dump includes commands like ALTER

Re: [GENERAL] PostgreSQL Developer Full-time Position

2006-12-12 Thread Merlin Moncure
On 12/12/06, Andrew Chernow [EMAIL PROTECTED] wrote: Our Company: eSilo is a privately held Storage Service Provider, providing offsite backup and storage management solutions to businesses of all sizes. eSilo built its backup technology in house and continues to expand and innovate. For more

Re: [GENERAL] Why DISTINCT ... DESC is slow?

2006-12-12 Thread Erik Jones
Ron Johnson wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/12/06 01:28, Anton wrote: Hi. With this table (about 800 000 rows): =# \d n_traffic Table public.n_traffic Column|Type | Modifiers

[GENERAL] Are updateable view as a linked table in ms-access a bad idea?

2006-12-12 Thread Richard Broersma Jr
I expect what I am reporting is already a known problem, but since I haven't heard anyone else report it I thought I should at least mention it. I am also looking for suggestions from anyone about how they prefer to bind forms to multiple hierarchial tables in access. I tried to wrap them is

[GENERAL] resetting sequence to cur max value

2006-12-12 Thread developer
I am migrating a system from hsqldb to postgresql. I have a bunch of installs of this system live so moving the data is a headache. I was using identities in hsqldb and now I am using sequences. I was able to move all my data over however I am having an issue with the sequences. I default them

[GENERAL] date comparisons

2006-12-12 Thread Belinda M. Giardine
This should be simple but I am missing something. I am trying to extract all records entered after a given date. The table has a field date_entered which is a timestamp. In this particular case I am not worried about time. I have tried: select id from main_table where date_entered

Re: [GENERAL] Why DISTINCT ... DESC is slow?

2006-12-12 Thread Brandon Aiken
If you have, say, an index(x, y) then that index will often double as an index(x). It will generally not double as an index(y). I'm not sure if that's how all RDBMSs work, but I'm pretty sure that's how Oracle works. It never surprises me when PostgreSQL mimics Oracle. -- Brandon Aiken CS/IT

Re: [GENERAL] Running initdb from another process

2006-12-12 Thread Tony Caduto
Greg Fairbanks wrote: Hi, I am looking at trying to integrate PostgreSQL into our software. Basically, I want to have our software to spawn postgres so the user doesn’t have to concern themselves with managing the database. I am using the Windows calls LogonUser and CreateProcessAsUser

Re: [GENERAL] date comparisons

2006-12-12 Thread Erik Jones
Belinda M. Giardine wrote: This should be simple but I am missing something. I am trying to extract all records entered after a given date. The table has a field date_entered which is a timestamp. In this particular case I am not worried about time. I have tried: select id from main_table

[GENERAL] a question on SQL

2006-12-12 Thread Tomi N/A
Don't really know where to ask this...the general mailing list sounds like the closest. Let's say I have three tables: owner, factory and product with a 1:N relationship at each step. Assuming that a product has a production date, how would you go about returning a factory for every owner, where

Re: [GENERAL] Unrecognized time zone name error.

2006-12-12 Thread Brad Nicholson
On Tue, 2006-12-12 at 11:13 -0500, Tom Lane wrote: Brad Nicholson [EMAIL PROTECTED] writes: This seems odd. Any idea what's going on here? template1=# SET TimeZone TO 'GMT'; ERROR: unrecognized time zone name: GMT Worksforme. Perhaps you are missing the /usr/share/pgsql/timezone/

Re: [GENERAL] resetting sequence to cur max value

2006-12-12 Thread Marc Mamin
I would create a small function with the sequence_name and reference_table as parameters (not tested) ... DECLARE newvalue int; rec record; BEGIN For rec in EXECUTE 'Select into newvalue max(id) as m from '||$2 loop EXECUTE 'ALTER SEQUENCE '||$1||' restart with '||rec.m; End loop;

Re: [GENERAL] date comparisons

2006-12-12 Thread Belinda M. Giardine
On Tue, 12 Dec 2006, Erik Jones wrote: Belinda M. Giardine wrote: This should be simple but I am missing something. I am trying to extract all records entered after a given date. The table has a field date_entered which is a timestamp. In this particular case I am not worried about

Re: [GENERAL] a question on SQL

2006-12-12 Thread Ragnar
On þri, 2006-12-12 at 16:47 +, Tomi N/A wrote: Don't really know where to ask this...the general mailing list sounds like the closest. Let's say I have three tables: owner, factory and product with a 1:N relationship at each step. Assuming that a product has a production date, how would

Re: [GENERAL] a question on SQL

2006-12-12 Thread Marc Mamin
Seems that a recursive use of DISTINCT ON will do it: create table factories (id int, factory varchar(10), ownerid int); create table products (id int, product varchar(10), atime int ,factory_id int); --owner 1 : factory 1 insert into products values(1,'p1',123,1); insert into products

Re: [GENERAL] date comparisons

2006-12-12 Thread Richard Huxton
Belinda M. Giardine wrote: Thanks that works. But I am trying to understand why the others did not, especially my first attempt. Further testing shows that select id, date_entered from main_table where date_entered = to_timestamp('2006 January', ' Month'); works, but select id,

Re: [GENERAL] resetting sequence to cur max value

2006-12-12 Thread Tom Lane
[EMAIL PROTECTED] writes: Is there a way to set it up so it knows to skip past existing ids? Usually you do something like select setval('seq_name', (select max(idcol) from table) + 1); after loading data into the table. regards, tom lane

Re: [GENERAL] resetting sequence to cur max value

2006-12-12 Thread developer
Awesome. Thanks tom. By the way I am still trying to find a yum install for 8.2 for centos...anyone? [EMAIL PROTECTED] writes: Is there a way to set it up so it knows to skip past existing ids? Usually you do something like select setval('seq_name', (select max(idcol) from table) +

Re: [GENERAL] Restore database from files (not dump files)?

2006-12-12 Thread Bruce Momjian
Tom Lane wrote: wheel [EMAIL PROTECTED] writes: I guess the reason is that the pg system database etc are lodged in the hive under \base\, and the system db contains the metadata about the db to be restored? No, the reason why selective restore doesn't work is that all tables in a

Re: [GENERAL] date comparisons

2006-12-12 Thread Tom Lane
Belinda M. Giardine [EMAIL PROTECTED] writes: Should it be this way? Well, to_timestamp() is apparently designed not to complain when the input doesn't match the format, which is not my idea of good behavior ... but your example is in fact wrong. 'Month' means a 9-character field, so you are

Re: [GENERAL] shell script to populate array values

2006-12-12 Thread Paul Silveira
Thanks Susan... I really appreciate your answer and helping me do what I wanted to do... I posted the code I was working on here... http://people.planetpostgresql.org/paul/ It's a pretty cool script and although it's not even done yet, I'm sure it could be useful to anyone wanting to do the

Re: [GENERAL] Why DISTINCT ... DESC is slow?

2006-12-12 Thread Tom Lane
Brandon Aiken [EMAIL PROTECTED] writes: If you have, say, an index(x, y) then that index will often double as an index(x). It will generally not double as an index(y). It's not hard to understand why, if you think about the sort ordering of a double-column index: x y 1

Re: [GENERAL] date comparisons

2006-12-12 Thread Belinda M. Giardine
On Tue, 12 Dec 2006, Tom Lane wrote: Belinda M. Giardine [EMAIL PROTECTED] writes: Should it be this way? Well, to_timestamp() is apparently designed not to complain when the input doesn't match the format, which is not my idea of good behavior ... but your example is in fact wrong.

Re: [GENERAL] Why DISTINCT ... DESC is slow?

2006-12-12 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/12/06 11:30, Tom Lane wrote: Brandon Aiken [EMAIL PROTECTED] writes: If you have, say, an index(x, y) then that index will often double as an index(x). It will generally not double as an index(y). It's not hard to understand why, if you

Re: [GENERAL] date comparisons

2006-12-12 Thread Richard Huxton
Tom Lane wrote: Belinda M. Giardine [EMAIL PROTECTED] writes: Should it be this way? Well, to_timestamp() is apparently designed not to complain when the input doesn't match the format, which is not my idea of good behavior ... but your example is in fact wrong. 'Month' means a 9-character

Re: [GENERAL] date comparisons

2006-12-12 Thread Tom Lane
Richard Huxton dev@archonet.com writes: The padding is on *input* too? Is this an Oracle compatibility feature? I assume so. If Oracle does not work like that, then it'd be a bug ... but the whole purpose of that function is to be Oracle-compatible, so we're sort of stuck doing what Oracle

Re: [GENERAL] Are updateable view as a linked table in ms-access a bad idea?

2006-12-12 Thread Richard Broersma Jr
Please show us your exact view, table and rule definitions used by this example. -- update 0 is false I guess what you are seeing are partial updates of the view caused by a multi-action rule which doesn't see the updated tuple in its subsequent actions anymore. This

Re: [GENERAL] a question on SQL

2006-12-12 Thread Tomi N/A
Ragnar, Marc, thanks so much for the help: DISTINCT ON was *exactly* what I needed. It's not a part of any SQL standard I know of, but does the job _wonderfully_. Cheers, t.n.a. ---(end of broadcast)--- TIP 4: Have you searched our list archives?

[GENERAL] Database-based alternatives to tsearch2?

2006-12-12 Thread Wes
I've seen questions asked on the list about alternatives to tsearch2, but not for the type of full text indexing I'm looking for. I'm looking for a non index-based full text indexing - one that stores the information as table data instead of index data. I do not need to implement SQL operators

Re: [GENERAL] Database-based alternatives to tsearch2?

2006-12-12 Thread Jeff Davis
On Tue, 2006-12-12 at 12:19 -0600, Wes wrote: I'm looking for a non index-based full text indexing - one that stores the information as table data instead of index data. I do not need to implement SQL operators for searches. The application library would need to implement the actual word

Re: [GENERAL] Asynchronous replication of a PostgreSQL DB to

2006-12-12 Thread Bruce Momjian
I think Sequoia (open source) and Continuent (proprietary) do this. --- Markus Wollny wrote: Hi! I'd like to export schema and data from a PostgreSQL database to a remote MySQL database; any changes to the PG-master

Re: [GENERAL] Database-based alternatives to tsearch2?

2006-12-12 Thread Richard Huxton
Wes wrote: Indexes are too fragile. Our documents will be offline, and re-indexing would be impossible. Additionally, as I undertstand it, tsearch2 doesn't scale to the numbers I need (hundreds of millions of documents). Jeff's right about tsvector - sounds like it's what you're looking

Re: [GENERAL] Database-based alternatives to tsearch2?

2006-12-12 Thread Daniel Verite
Wes wrote: I've seen questions asked on the list about alternatives to tsearch2, but not for the type of full text indexing I'm looking for. I'm looking for a non index-based full text indexing - one that stores the information as table data instead of index data. I do not need to

Re: [GENERAL] PostgreSQL 8.2 : IPO link warning with ICC 9.1.045

2006-12-12 Thread Martijn van Oosterhout
On Tue, Dec 12, 2006 at 04:06:55PM +0100, DANTE Alexandra wrote: But when I check the log of the rpmbuild -ba command, I have found this warning : snip *IPO link: Warning unknown option '--version-script=exports.list'.* That the gcc command-line switch used to stop exporting unnessesary

Re: [GENERAL] a question on SQL

2006-12-12 Thread Martijn van Oosterhout
On Tue, Dec 12, 2006 at 06:29:07PM +, Tomi N/A wrote: Ragnar, Marc, thanks so much for the help: DISTINCT ON was *exactly* what I needed. It's not a part of any SQL standard I know of, but does the job _wonderfully_. It's the single most useful non-standard SQL feature postgresql has. It

Re: [GENERAL] Online index builds

2006-12-12 Thread Bruce Momjian
Jeff Davis wrote: On Thu, 2006-12-07 at 18:11 -0500, Tom Lane wrote: Jeff Davis [EMAIL PROTECTED] writes: I think all you need to do what you want is something like: ALTER TABLE foo DROP CONSTRAINT foo_pkey KEEP INDEX; Because then you could drop the primary key status on a column

Re: [GENERAL] Online index builds

2006-12-12 Thread Bruce Momjian
bruce wrote: Jeff Davis wrote: On Thu, 2006-12-07 at 18:11 -0500, Tom Lane wrote: Jeff Davis [EMAIL PROTECTED] writes: I think all you need to do what you want is something like: ALTER TABLE foo DROP CONSTRAINT foo_pkey KEEP INDEX; Because then you could drop the primary key

Re: [GENERAL] PostgreSQL 8.2 : IPO link warning with ICC 9.1.045

2006-12-12 Thread Tom Lane
Martijn van Oosterhout kleptog@svana.org writes: That the gcc command-line switch used to stop exporting unnessesary symbols. It should only be used for gcc, I wonder how it selected it for your compiler? Did you run configure with the right compiler? icc pretends to be gcc ... not very well,

Re: [GENERAL] search_path when restoring to new db

2006-12-12 Thread SunWuKung
I think there should be an easier way to backup a single database and restore it on another server. In my case we are developing a db so there are many schema changes to that. When there is a significant change we find it easier to drop and recreate the db from the backup - withouth affecting the

Re: [GENERAL] a question on SQL

2006-12-12 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ragnar, Marc, thanks so much for the help: DISTINCT ON was *exactly* what I needed. It's not a part of any SQL standard I know of, but does the job _wonderfully_. It's the single most useful non-standard SQL feature postgresql has. It is thus

[GENERAL] Postgres friendly RegEx?

2006-12-12 Thread Jon Asher
Anyone care to correct this regex for PostgreSQL? It works in C++ but Postgres have no love for it: -{0,1}\d*\.{0,1}\d+\^{0,1}\d*\.{0,1}\d+ This regex accepts (any num)^(pos num) such as: 45.2^3 -45.2^3 10^2.5

Re: [GENERAL] search_path when restoring to new db

2006-12-12 Thread Tom Lane
SunWuKung [EMAIL PROTECTED] writes: The way I found out that I have to create language before and set the searchpath after running restore is that I found that the restored db doesn't work - which was quite scary at first. You should not need to create the language --- that *is* part of the

Re: [GENERAL] a question on SQL

2006-12-12 Thread Tom Lane
Greg Sabino Mullane [EMAIL PROTECTED] writes: It's the single most useful non-standard SQL feature postgresql has. It is thus simultaneously bad (from a portatbility aspect) and brilliant (because it's a million times easier and faster than the alternatives). You mean second-most useful.

Re: [GENERAL] Postgres friendly RegEx?

2006-12-12 Thread Tom Lane
Jon Asher [EMAIL PROTECTED] writes: Anyone care to correct this regex for PostgreSQL? It works in C++ but Postgres have no love for it: -{0,1}\d*\.{0,1}\d+\^{0,1}\d*\.{0,1}\d+ It works fine in Postgres, AFAICT. Maybe you forgot to double the backslashes in a string literal? Otherwise, be

Re: [GENERAL] Postgres friendly RegEx?

2006-12-12 Thread Jon Asher
In Postgres, it appears to be returning false positives: select * from (select '52'::varchar As val) d where d.val ~ '-{0,1}\\d*\\.{0,1}\\d+\\^{0,1}\\d*\\.{0,1}\\d+' returns a record. In C++ only such values match: 45.2^3 or -45.2^3 or 10^2.5 On 12/12/06, Tom Lane [EMAIL PROTECTED]

Re: [GENERAL] Postgres friendly RegEx?

2006-12-12 Thread Jon Asher
Please ignore, my mistake in the translation to Pg regex ! On 12/12/06, Jon Asher [EMAIL PROTECTED] wrote: In Postgres, it appears to be returning false positives: select * from (select '52'::varchar As val) d where d.val ~ '-{0,1}\\d*\\.{0,1}\\d+\\^{0,1}\\d*\\.{0,1}\\d+' returns a record.

[GENERAL] indexed function performance

2006-12-12 Thread mikelin
I'm trying to do a complicated ordering of a table with ~40k rows. I have an IMMUTABLE plpgsql function that returns an integer that I'll be sorting by, but the function is slow, so I want to cache it somehow. I found in the docs: the index expressions are not recomputed during an indexed

Re: [GENERAL] Online index builds

2006-12-12 Thread Tom Lane
Gregory Stark [EMAIL PROTECTED] writes: You could create a whole new index concurrently, then in a completely new (third) transaction drop the old one. The problem there is that there could be other things (namely foreign key constraints) depending on the old index. Fixing them all to depend

Re: [GENERAL] indexed function performance

2006-12-12 Thread Tom Lane
mikelin [EMAIL PROTECTED] writes: which sounds like caching, so I created an index on that function, expecting stellar performance, but the performance turned out to be pretty bad: words=# explain analyse select * from word order by word_difficulty(word) limit 100; I wouldn't have expected

[GENERAL] TIMESTAMP WITHOUT TIME ZONE

2006-12-12 Thread Randy Shelley
I am stuck, I am getting two different times from the database depending on the timezone of the system I am querying from. The story is this: I have a table name request. It has a column create_dt of type TIMESTAMP WITHOUT TIME ZONE. When I query this from jdbc into a java.sql.Timestamp and out

[GENERAL] Statement timeout not working on broken connections with active queries

2006-12-12 Thread Brendan O'Shea
We have discovered a situation where the statement_timeout is not honored for broken connections. If a connection is in the process of returning results to the client and the connection is severed (for example, network cable on client is unplugged) then the query continues to run on the server

Re: [GENERAL] Postgres friendly RegEx?

2006-12-12 Thread Jeremy Harris
You don't give a pg version. It looks legal to me as of 8.1. Try replacing all the {0,1} with ? - but check the manual for regex_flavor too. Is there any chance you're in basic mode? - Jeremy ---(end of broadcast)--- TIP 5: don't forget to

Re: [GENERAL] TIMESTAMP WITHOUT TIME ZONE

2006-12-12 Thread Tom Lane
Randy Shelley [EMAIL PROTECTED] writes: The java.sql.Timestamp does not store any timezone info, just nano seconds from a date. One would hope that it's implicitly referenced to GMT, though, not some free-floating value that means who-knows-what. I think your fundamental error is in using

Re: [GENERAL] Statement timeout not working on broken connections with active queries

2006-12-12 Thread Tom Lane
Brendan O'Shea [EMAIL PROTECTED] writes: We have discovered a situation where the statement_timeout is not = honored for broken connections. If a connection is in the process of = returning results to the client and the connection is severed (for = example, network cable on client is

Re: [GENERAL] Online index builds

2006-12-12 Thread Jeff Davis
On Tue, 2006-12-12 at 18:08 -0500, Tom Lane wrote: Gregory Stark [EMAIL PROTECTED] writes: You could create a whole new index concurrently, then in a completely new (third) transaction drop the old one. The problem there is that there could be other things (namely foreign key

Re: [GENERAL] shell script to populate array values

2006-12-12 Thread Paul Silveira
I wonder if I could ask another question on this thread... How would i get the latest ID value of a table in psql and then use that value as part of an insert statement... For example... I would like ot declare a variable in a shell script and then use that value in the insert statement later

Re: [GENERAL] Online index builds

2006-12-12 Thread Gregory Stark
Jeff Davis [EMAIL PROTECTED] writes: I think what I'm confused about is how these non-transactional commands work (like VACUUM, etc). Are they still transactions, and just can't be run in a block? In the case of CREATE INDEX CONCURRENTLY it can't be run in a transaction block because it

Re: [GENERAL] Statement timeout not working on broken connections with active queries

2006-12-12 Thread Brian Wipf
On 12-Dec-06, at 4:30 PM, Tom Lane wrote: Brendan O'Shea [EMAIL PROTECTED] writes: We have discovered a situation where the statement_timeout is not = honored for broken connections. If a connection is in the process of = returning results to the client and the connection is severed (for =

Re: [GENERAL] Online index builds

2006-12-12 Thread Tom Lane
Jeff Davis [EMAIL PROTECTED] writes: My point was that, because we can run it in multiple transactions, can't we drop the nonexclusive lock before acquiring the exclusive lock, No. What happens if someone renames the table out from under you, to mention just one possibility? If you've been

Re: [GENERAL] PITR and moving objects between table spaces

2006-12-12 Thread Glen Parker
You can probably make this work if you don't issue any CREATE TABLESPACE commands while PITR logging is active, but you'll want to test your procedures pretty carefully. That's what I thought, and after your message, I went ahead with it and had no problems. Thx, Tom. -Glen

Re: [GENERAL] Online index builds

2006-12-12 Thread Jeff Davis
On Tue, 2006-12-12 at 18:40 -0500, Tom Lane wrote: Jeff Davis [EMAIL PROTECTED] writes: My point was that, because we can run it in multiple transactions, can't we drop the nonexclusive lock before acquiring the exclusive lock, No. What happens if someone renames the table out from under

Re: [GENERAL] Online index builds

2006-12-12 Thread Tom Lane
Jeff Davis [EMAIL PROTECTED] writes: On Tue, 2006-12-12 at 18:40 -0500, Tom Lane wrote: No. What happens if someone renames the table out from under you, to mention just one possibility? I'm trying to understand what would actually happen. I assume you mean change the name of the index,

Re: [GENERAL] shell script to populate array values

2006-12-12 Thread SCassidy
What's stopping you from using the variable? It works fine for me. The only problem I see is that you are quoting an integer value (SELECT '$SERVERCOLLECTIONTIMEID', column1 FROM mytable;) for no reason (leave off the single quotes around $SERVERCOLLECTIONTIMEID), although it does not seem to

Re: [GENERAL] Online index builds

2006-12-12 Thread Jeff Davis
On Tue, 2006-12-12 at 19:13 -0500, Tom Lane wrote: Jeff Davis [EMAIL PROTECTED] writes: On Tue, 2006-12-12 at 18:40 -0500, Tom Lane wrote: No. What happens if someone renames the table out from under you, to mention just one possibility? I'm trying to understand what would actually

  1   2   >