Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Geoffrey
Worik wrote: Assuming it is unix The command ps xau|grep post You might want to change that to: ps aux|grep postgres As your suggestion will pick up extraneous data if one is running postfix on the same box. -- Until later, Geoffrey Registered Linux User #108567

[SQL] ORDER BY and NULLs

2004-09-19 Thread T E Schmitz
Hello, I am using PostgreSQL 7.4.2 and as I understand NULL values always sort last. However, I have a table from which select using two numerical sort keys FROM and TO. TO might be NULL and I would like to display those rows first (without sorting the column in descending order). Is there

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Jean-Luc Lachance
select ... order by FROM is not null, FROM; If you have large amount of rows (with or without nulls) it is faster if use a partial index. create index ... on ...(FROM); create index ... on ...(FROM) where FROM is null; JLL [EMAIL PROTECTED] wrote: Use the coalesce() function. (coalesce returns

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Tom Lane
Geoffrey [EMAIL PROTECTED] writes: Worik wrote: Assuming it is unix The command ps xau|grep post You might want to change that to: ps aux|grep postgres As your suggestion will pick up extraneous data if one is running postfix on the same box. Actually I'd recommend grepping for

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread T E Schmitz
Hello Jean-Luc, You must've been reading my mind. I was just wondering what to do about indexing on that particular table. I read somewhere that an Index is not going to improve the performance of an ORDER BY if the sort column contains NULLs because NULLs aren't indexed? For the sake of the

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Andrew Sullivan
On Sun, Sep 19, 2004 at 12:25:00PM -0400, Tom Lane wrote: ps aux | grep postmaster | grep -v grep (or use ps -ef if using a SysV-ish ps). Except that on Solaris, ps -ef _always_ shows postmaster, even for the individual back ends. A -- Andrew Sullivan | [EMAIL PROTECTED] In the future

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Tom Lane
T E Schmitz [EMAIL PROTECTED] writes: You must've been reading my mind. I was just wondering what to do about indexing on that particular table. I read somewhere that an Index is not going to improve the performance of an ORDER BY if the sort column contains NULLs because NULLs aren't

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Tom Lane
Andrew Sullivan [EMAIL PROTECTED] writes: On Sun, Sep 19, 2004 at 12:25:00PM -0400, Tom Lane wrote: ps aux | grep postmaster | grep -v grep (or use ps -ef if using a SysV-ish ps). Except that on Solaris, ps -ef _always_ shows postmaster, even for the individual back ends. Right, but if you

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread T E Schmitz
Hello Tom, Tom Lane wrote: T E Schmitz [EMAIL PROTECTED] writes: I read somewhere that an Index is not going to improve the performance of an ORDER BY if the sort column contains NULLs because NULLs aren't indexed? Whatever you were reading had it pretty badly garbled :-( I just dug out the

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Greg Stark
T E Schmitz [EMAIL PROTECTED] writes: I just dug out the PostgreSQL book again because I thought I might've garbled it: Quote: PostgreSQL will not index NULL values. Because an index will never include NULL values, it cannot be used to satisfy the ORDER BY clause of a query that returns

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Tom Lane
T E Schmitz [EMAIL PROTECTED] writes: Tom Lane wrote: Whatever you were reading had it pretty badly garbled :-( I just dug out the PostgreSQL book again because I thought I might've garbled it: Quote: PostgreSQL will not index NULL values. Because an index will never include NULL values,

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread T E Schmitz
Hello Greg, Greg Stark wrote: T E Schmitz [EMAIL PROTECTED] writes: Quote: PostgreSQL will not index NULL values. Because an index will never include NULL values, it cannot be used to satisfy the ORDER BY clause of a query that returns all rows in a table. You should just cross out that whole

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Tom Lane
T E Schmitz [EMAIL PROTECTED] writes: Greg Stark wrote: Which book is it? PostgreSQL by Korry Douglas + Susan Douglas, ISBN 0-7357-1257-3; Feb 2003 Hmm, I've heard of that book but never seen it. The authors are not participants in the PG community --- AFAICT neither of them have ever posted

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread T E Schmitz
Hello Tom, Tom Lane wrote: T E Schmitz [EMAIL PROTECTED] writes: Greg Stark wrote: Which book is it? PostgreSQL by Korry Douglas + Susan Douglas, ISBN 0-7357-1257-3; Feb 2003 Hmm, I've heard of that book but never seen it. The authors are not participants in the PG community --- AFAICT neither

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Gaetano Mendola
Jeff Eckermann wrote: --- Christopher Browne [EMAIL PROTECTED] wrote: In an attempt to throw the authorities off his trail, [EMAIL PROTECTED] (Sandeep Gaikwad) transmitted: Hello Sir, I want to know how to check whether postgres database is running or not ? when I give command

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Gaetano Mendola
Tom Lane wrote: Geoffrey [EMAIL PROTECTED] writes: Worik wrote: Assuming it is unix The command ps xau|grep post You might want to change that to: ps aux|grep postgres As your suggestion will pick up extraneous data if one is running postfix on the same box. Actually I'd recommend grepping

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Andrew Sullivan
On Sun, Sep 19, 2004 at 01:12:07PM -0400, Tom Lane wrote: Except that on Solaris, ps -ef _always_ shows postmaster, even for the individual back ends. Right, but if you see a backend then you can figure the system is up. Oops, good point. (And in any case, on Solaris you also have the ucb

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Worik
[snip] Just to enforce the test is better looking for the entire executable path: ps aux | grep /usr/bin/postmaster | grep -v grep Does not work for me! [EMAIL PROTECTED]:~$ ps aux | grep /usr/bin/postmaster | grep -v grep [EMAIL PROTECTED]:~$ ps aux | grep postmaster | grep -v grep

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Greg Stark
Tom Lane [EMAIL PROTECTED] writes: The paragraph continues: If the SELECT command included the clause WHERE phone NOT NULL, PostgreSQL could use the index to satisfy the ORDER BY clause. An index that covers optional (NOT NULL) columns will not be used to speed table joins either.

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Worik
Perhaps I have a bug in pg_ctrl? This is what I get... [EMAIL PROTECTED]:~$ ps aux | grep postmaster | grep -v grep ;/usr/lib/postgresql/bin/pg_ctl status postgres 670 0.0 0.6 8544 1688 pts/1S12:33 0:00 /usr/lib/postgresql/bin/postmaster pg_ctl: postmaster or postgres is not

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Tom Lane
Worik [EMAIL PROTECTED] writes: Perhaps I have a bug in pg_ctrl? More likely you have the wrong value of PGDATA in your environment (where wrong means not what that postmaster is using). regards, tom lane ---(end of

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Arne Stoelck
How about a simple telnet localhost 5432 ? assuming postmaster is listening on that host and port On Fri, 17 Sep 2004, Sandeep Gaikwad wrote: Hello Sir, I want to know how to check whether postgres database is running or not ? when I give command like ./postmaster -i , whether

[SQL] Test for file exists?

2004-09-19 Thread Richard Sydney-Smith
I want to use pgsql to send the command: Copy sometable from 'sometable.csv'; But only if 'sometable.csv' exists; If 'sometable.csv' does not exist as an input table I want to continue the next command. My full procedure is as follows and any help is greatly appreciated. Thanks Richard