[GENERAL] Copy command to handle view for my export requirement

2011-08-11 Thread Siva Palanisamy
Hi All, I understand that copy and \copy commands in PostgreSQL work only for tables. I want it to export the data from varies tables. Instead, I can create a view for the list of tables. Can the copy or \copy commands be utilized to operate on views directly? Please let me know on this. Thank

Re: [GENERAL] Copy command to handle view for my export requirement

2011-08-11 Thread Andreas Kretschmer
Siva Palanisamy wrote: > Hi All, > > > > I understand that copy and \copy commands in PostgreSQL work only for tables. > I > want it to export the data from varies tables. Instead, I can create a view > for > the list of tables. Can the copy or \copy commands be utilized to operate on > vie

[GENERAL] Can't Bringing the former Primary up as a Standby

2011-08-11 Thread Sergey Levchenko
Hello! I got: root@reactor:~# invoke-rc.d postgresql start Starting PostgreSQL 9.1 database server: mainThe PostgreSQL server failed to start. Please check the log output: 2011-08-11 12:12:42 EEST LOG: database system was interrupted; last known up at 2011-08-11 12:04:21 EEST 2011-08-11 12:12:42

Re: [GENERAL] Copy command to handle view for my export requirement

2011-08-11 Thread Siva Palanisamy
Hi Andreas, I tried the command as below. It failed. Please correct me. \copy (select * from view1) to '/sample.csv' delimiters ',' csv header; ERROR: \copy: parse error at "select" Thanks and Regards, Siva. -Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-gen

Re: [GENERAL] Copy command to handle view for my export requirement

2011-08-11 Thread Siva Palanisamy
Hi Andreas, FYI, I am using PostgreSQL 8.1.4. Thanks and Regards, Siva. -Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Siva Palanisamy Sent: Thursday, August 11, 2011 4:48 PM To: Andreas Kretschmer; pgsql-general@po

Re: [GENERAL] Copy command to handle view for my export requirement

2011-08-11 Thread Raghavendra
Nope, you need to be in latest version as Andreas said. --- Regards, Raghavendra EnterpriseDB Corporation Blog: http://raghavt.blogspot.com/ On Thu, Aug 11, 2011 at 4:51 PM, Siva Palanisamy wrote: > Hi Andreas, > > FYI, I am using PostgreSQL 8.1.4. > > Thanks and Regards, > Siva. > > > -O

Re: [GENERAL] Copy command to handle view for my export requirement

2011-08-11 Thread Boszormenyi Zoltan
Hi, COPY (SELECT ...) appeared in 8.2.x so you need to upgrade. Best regards, Zoltán Böszörményi 2011-08-11 13:21 keltezéssel, Siva Palanisamy írta: > Hi Andreas, > > FYI, I am using PostgreSQL 8.1.4. > > Thanks and Regards, > Siva. > > > -Original Message- > From: pgsql-general-ow...@p

Re: [GENERAL] Copy command to handle view for my export requirement

2011-08-11 Thread Siva Palanisamy
Hi, I have installed Windows version of Postgres 9.0.4 in my windows machine to test the new copy command as detailed in the below e-mails. When I run the command in SQL Editor, I got permission error. But I am running as an administrator. COMMAND: copy (select * from employee) to 'C:/emp.csv

Re: [GENERAL] Copy command to handle view for my export requirement

2011-08-11 Thread Raghavendra
> > COMMAND: copy (select * from employee) to 'C:/emp.csv' > ERROR: could not open file "C:/emp.csv" for writing: Permission denied > ** Error ** > ERROR: could not open file "C:/emp.csv" for writing: Permission denied > SQL state: 42501 > > COMMAND: \copy (select * from employee)

Re: [GENERAL] Copy command to handle view for my export requirement

2011-08-11 Thread Craig Ringer
On 11/08/2011 7:56 PM, Siva Palanisamy wrote: > FYI, I am using PostgreSQL 8.1.4. Argh, ogod why?!?!?! That version is *totally* unsupported on Windows. Not only that, but you're running an ancient point-release - you are missing *19* patch releases worth of bug fixes. The latest point-releas

Re: [GENERAL] Copy command to handle view for my export requirement

2011-08-11 Thread Raghavendra
> > > You are not using psql. "\copy" is a psql command. I don't think it's > supported by PgAdmin III, though I could be wrong. > > Right, '\copy' is not supported in PgAdmin III. --Raghav

Re: [GENERAL] streaming replication: one problem & several questions

2011-08-11 Thread Pedro Sam
Do your machines have the same architecture? (64 bit vs 32 bit) - This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or

Re: [GENERAL] streaming replication: one problem & several questions

2011-08-11 Thread Lonni J Friedman
On Thu, Aug 11, 2011 at 8:17 AM, Pedro Sam wrote: > Do your machines have the same architecture?  (64 bit vs 32 bit) Yes, they're all Fedora15-x86_64. -- ~ L. Friedman                                    netll...@gmail.com Llam

[GENERAL] Final 48 for PgWest CFP

2011-08-11 Thread Joshua D. Drake
Hello, We are in the final 48 hours of the CFP for PgWest. Let's get those talks in. https://www.postgresqlconference.org/talk_types Sincerely, Joshua D. Drake -- Command Prompt, Inc. - http://www.commandprompt.com/ PostgreSQL Support, Training, Professional Services and Development The Pos

Re: [GENERAL] is max connections in a database table somewhere

2011-08-11 Thread Diego Augusto Molina
2011/8/10, Greg Smith : > On 08/10/2011 02:46 PM, Geoffrey Myers wrote: >> Is the max connections value in a system table somewhere? Yes, it is in the table "pg_catalog.pg_database". The column is named "datconnlimit" and is of type "int4". See this: http://www.postgresql.org/docs/9.0/interactive/

[GENERAL] FK violation on (emtpy) parent table

2011-08-11 Thread Louis-David Mitterrand
Hi, I have an empty parent 'price' table with several partitioned child tables that contain the actual data. How can I reference the parent 'price' table in a FK? When I try I get a FK violation. Is that expected behavior? Is there another way to do it? Thanks, -- Sent via pgsql-general mailin

[GENERAL] Filling Missing Primary Key Values

2011-08-11 Thread Rich Shepard
I've a table (from a client, not created here) with a column that should be the primary key, but not all rows have a value for this attribute. The column format is VARCHAR(12) and has a variety of values, such as 96-A000672 and 9612-0881 (probably assigned by different analytical laboratories).

Re: [GENERAL] Filling Missing Primary Key Values

2011-08-11 Thread Chris Travers
On Thu, Aug 11, 2011 at 11:47 AM, Rich Shepard wrote: >  I've a table (from a client, not created here) with a column that should > be the primary key, but not all rows have a value for this attribute. The > column format is VARCHAR(12) and has a variety of values, such as 96-A000672 > and 9612-08

Re: [GENERAL] Filling Missing Primary Key Values

2011-08-11 Thread Rich Shepard
On Thu, 11 Aug 2011, Chris Travers wrote: The simplest seems to me to be a sequence and use nextval() to populate the null values. The major advantage would be that the sequence could stay around in case you need it again. So for example: create sequence my_varchar_values; UPDATE my_table se

Re: [GENERAL] Filling Missing Primary Key Values

2011-08-11 Thread Chris Travers
On Thu, Aug 11, 2011 at 12:34 PM, Rich Shepard wrote: > On Thu, 11 Aug 2011, Chris Travers wrote: > >> The simplest seems to me to be a sequence and use nextval() to populate >> the null values. The major advantage would be that the sequence could stay >> around in case you need it again. So for e

Re: [GENERAL] Filling Missing Primary Key Values

2011-08-11 Thread David Johnston
On Aug 11, 2011, at 15:08, Chris Travers wrote: > On Thu, Aug 11, 2011 at 11:47 AM, Rich Shepard > wrote: >> I've a table (from a client, not created here) with a column that should >> be the primary key, but not all rows have a value for this attribute. The >> column format is VARCHAR(12) and

Re: [GENERAL] Filling Missing Primary Key Values

2011-08-11 Thread Steve Atkins
On Aug 11, 2011, at 12:34 PM, Rich Shepard wrote: > On Thu, 11 Aug 2011, Chris Travers wrote: > >> The simplest seems to me to be a sequence and use nextval() to populate >> the null values. The major advantage would be that the sequence could stay >> around in case you need it again. So for exa

Re: [GENERAL] Is max connections in a table somewhere?

2011-08-11 Thread Geoffrey Myers
Adrian Klaver wrote: On Wednesday, August 10, 2011 11:47:25 am Geoffrey Myers wrote: Is max connections in any table in the database I can access? SELECT current_setting('max_connections'); current_setting - 100 Thanks for all the responses folks. Obviously, there's mor

Re: [GENERAL] is max connections in a database table somewhere

2011-08-11 Thread Geoffrey Myers
Greg Smith wrote: On 08/10/2011 02:46 PM, Geoffrey Myers wrote: Is the max connections value in a system table somewhere? If you intend to do anything with the value you probably want one of these forms: SELECT CAST(current_setting('max_connections') AS integer); SELECT CAST(setting AS inte

Re: [GENERAL] Filling Missing Primary Key Values

2011-08-11 Thread Rich Shepard
On Thu, 11 Aug 2011, Steve Atkins wrote: This will fail if any of the existing values are integers in the range that you're inserting - and it may fail in the future, as you add new records if they clash with existing entries. Steve/Chris/Dave: I had not looked in deatil at that column befo

[GENERAL] Regex Query Index question

2011-08-11 Thread Naoko Reeves
Hello, I have query phone number in database as follows: [123) 456-7890 (123) 456-7890 When I query like this: SELECT * FROM phone WHERE phone_number ~ ('^\[123' || '[-\s\)]{0,2}' || '456' || '[-\s\)]{0,2}' || '7890') it use Index but if I query like this (notice first character is open paren

Re: [HACKERS] [GENERAL] Dropping extensions

2011-08-11 Thread Marc Munro
On Sat, 2011-07-30 at 22:46 +0200, Dimitri Fontaine wrote: > Tom Lane writes: > > Hmm. I don't think we have any code in there to prohibit the same > > object from being made a member of two different extensions ... but this > > example suggests that maybe we had better check that. > > I see you

Re: [GENERAL] Regex Query Index question

2011-08-11 Thread Tom Lane
Naoko Reeves writes: > I have query phone number in database as follows: > [123) 456-7890 > (123) 456-7890 > When I query like this: > SELECT * FROM phone > WHERE phone_number ~ ('^\[123' || '[-\s\)]{0,2}' || '456' || '[-\s\)]{0,2}' > || '7890') > it use Index but if I query like this (notice

Re: [GENERAL] Regex Query Index question

2011-08-11 Thread Naoko Reeves
Tom, Thank you for your quick reply. Data start with "(123" only returns 28 records where as phone number start with"[123" returns 1. Changed the data so that both will return 1 row. One with "(999" query takes about 30 seconds (30983ms) without index. One with "[999" take about 28 ms with index.

[GENERAL] COPY from .csv File and Remove Duplicates

2011-08-11 Thread Rich Shepard
A table has a sequence to generate a primary key for inserted records with NULLs in that column. I have a .csv file of approximately 10k rows to copy into this table. My two questions which have not been answered by reference to my postgres reference book or Google searches are: 1) Will th

[GENERAL] suggestions for archive_command to a remote standby

2011-08-11 Thread John DeSoi
rsync seems to be suggested in a number of references for the archive_command when copying WAL files to another server. But the documentation states in bold letters that the command should refuse to overwrite existing files, *and that it returns nonzero status in this case*. You can keep rsync f

Re: [GENERAL] suggestions for archive_command to a remote standby

2011-08-11 Thread Rich Shepard
On Thu, 11 Aug 2011, John DeSoi wrote: rsync seems to be suggested in a number of references for the archive_command when copying WAL files to another server. But the documentation states in bold letters that the command should refuse to overwrite existing files, *and that it returns nonzero sta

Re: [GENERAL] Regex Query Index question

2011-08-11 Thread David Johnston
On Aug 11, 2011, at 18:26, Naoko Reeves wrote: > Hello, > I have query phone number in database as follows: > [123) 456-7890 > > (123) 456-7890 > Store phone numbers without formatting...the data is the numbers themselves the formatting is presentation. > When I query like this: > > SELECT

Re: [GENERAL] COPY from .csv File and Remove Duplicates

2011-08-11 Thread David Johnston
On Aug 11, 2011, at 19:13, Rich Shepard wrote: > A table has a sequence to generate a primary key for inserted records with > NULLs in that column. > > I have a .csv file of approximately 10k rows to copy into this table. My > two questions which have not been answered by reference to my postg

Re: [GENERAL] Regex Query Index question

2011-08-11 Thread Tom Lane
Naoko Reeves writes: > Also forgot to mentioned the version: > select version() >> "PostgreSQL 8.4.6 on i386-apple-darwin, compiled by GCC > i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5370), Oh --- there's your problem. In 8.4 and earlier, we don't trust \( to be a lite

Re: [GENERAL] COPY from .csv File and Remove Duplicates

2011-08-11 Thread Rich Shepard
On Thu, 11 Aug 2011, David Johnston wrote: If you have duplicates with matching real keys inserting into a staging table and then moving new records to the final table is your best option (in general it is better to do a two-step with a staging table since you can readily use Postgresql to perfo

Re: [GENERAL] Regex Query Index question

2011-08-11 Thread David Johnston
Now that I read more closely the alternation is actually concatenation. My point still stands but your issue is that you have not created a functional index on the decryption result of the encrypted phone number. PostgreSQL does not know that the decrypted phone number is equivalent to the une

Re: [GENERAL] Regex Query Index question

2011-08-11 Thread David Johnston
> > Not testing here but... and ignore whitespace > > '^( [ \[\( ]? \s* \d{3} \s* [ -\s\]\) ] \d{3} [ -\s ] \d{4} )$' > Some tweaks needed but seriously consider dropping RegEx and going the functional index route. > '^( [ \[\( ]? \s* \d{3} \s* [ -\s\]\) ] \s* \d{3} \s* [ -\s ] \s* \d{4} )$'

Re: [GENERAL] Postgres on SSD

2011-08-11 Thread Ondrej Ivanič
Hi, 2011/8/11 Amitabh Kant : > There have been several discussions for SSD in recent months although not > specific to Fusion IO drives. > > See http://archives.postgresql.org/pgsql-general/2011-04/msg00460.php . You > can search the archives for more such reference. I've read this one several da

Re: [GENERAL] COPY from .csv File and Remove Duplicates

2011-08-11 Thread Craig Ringer
On 12/08/2011 7:13 AM, Rich Shepard wrote: I have a .csv file of approximately 10k rows to copy into this table. My two questions which have not been answered by reference to my postgres reference book or Google searches are: 1) Will the sequence automatically add the nextval() to each new reco

Re: [GENERAL] COPY from .csv File and Remove Duplicates

2011-08-11 Thread David Johnston
>> There is no true key, only an artificial key so I can ensure that rows are >> unique. That's in the main table with the 50K rows. No key column in the >> .csv file. If you have no true key then you have no way to ensure uniqueness. By adding an artificial key two records that are otherwise du

Re: [GENERAL] COPY from .csv File and Remove Duplicates

2011-08-11 Thread Craig Ringer
On 12/08/2011 10:32 AM, David Johnston wrote: The general structure for the insert would be: INSERT INTO maintable (cols) SELECT cols FROM staging WHERE staging.idcols NOT IN (SELECT maintable.idcols FROM maintable); There may be more efficient ways to write the query but the idea is the same.

Re: [GENERAL] Postgres on SSD

2011-08-11 Thread Greg Smith
On 08/09/2011 07:17 PM, Ondrej Ivanič wrote: I'm about to evaluate this SSD card: FusionIO ioDrive Duo [1]. The main reason for this experiment is to see if SSD can significantly improve query performance Database size is around ~1.4TB. Main tables occupied around 1/3 (450GB, ~220mil rows) and ag