Re: [SQL] SQL to Check whether AN HOUR PERIOD is between start and end timestamps

2009-04-02 Thread James Kitambara
Dear Srikanth, You can solve your problem by doing this THE SQL IS AS FOLLOWS   ASSUME TIME INTERVAL 2008-12-07 07:59:59 TO 2008-12-07 08:58:59 AND THE TABLE NAME time_interval  COUNT (*) FROM       (select customer_id, log_session_id, start_ts, end_ts , end_ts-start_ts as Interval from

Re: [SQL] SQL to Check whether AN HOUR PERIOD is between start and end timestamps

2009-04-02 Thread Alvaro Herrera
James Kitambara wrote: Dear Srikanth, You can solve your problem by doing this THE SQL IS AS FOLLOWS   ASSUME TIME INTERVAL 2008-12-07 07:59:59 TO 2008-12-07 08:58:59 AND THE TABLE NAME time_interval  COUNT (*) FROM       (select customer_id, log_session_id, start_ts, end_ts ,

[SQL] ibatis with overlaps query

2009-04-02 Thread Emi Lu
Good morning, With ibatis, do overlap checking: (1) select (DATE #begin_date#, DATE #end_date#) overlaps (DATE '2008-01-01', DATE '2009-01-01') . #begin_date# is varchar . #end_date# is varchar Always get: Cause: java.sql.SQLException: ERROR: syntax error at or near $4

Re: [SQL] Performance problem with row count trigger

2009-04-02 Thread Craig Ringer
Tony Cebzanov wrote: The throughput of the first batch of 1,000 is diminished, but still tolerable, but after 10,000 inserts, it's gotten much worse. This pattern continues, to the point where performance is unacceptable after 20k or 30k inserts. To rule out the performance of the trigger

Re: [SQL] Performance problem with row count trigger

2009-04-02 Thread Wei Weng
On 04/02/2009 03:32 PM, Tom Lane wrote: Tony Cebzanov tony...@andrew.cmu.edu writes: What I want to do is update the assoc_count field in the dataset table to reflect the count of related records in the assoc field. To do so, I added the following trigger:

Re: [SQL] Performance problem with row count trigger

2009-04-02 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 I was looking to speed up a count(*) query A few things spring to mind: 1) Use a separate table, rather than storing things inside of dataset itself. This will reduce the activity on the dataset table. 2) Do you really need bigint for the

[SQL] How would I get rid of trailing blank line?

2009-04-02 Thread Tena Sakai
Hi Everybody, I am using postgres 8.3.4 on linux. I often use a line like: psql -tf query.sql mydatabase query.out -t option gets rid of the heading and count report at the bottom. There is a blank line at the bottom, however. Is there any way to have psql not give me that blank line?

Re: [SQL] FUNCTION problem

2009-04-02 Thread Adrian Klaver
- Peter Willis pet...@borstad.com wrote: Adrian Klaver wrote: On Wednesday 01 April 2009 4:31:20 pm Peter Willis wrote: Hello, I am having a problem with a FUNCTION. The function creates just fine with no errors. However, when I call the function postgres produces an error.

Re: [SQL] How would I get rid of trailing blank line?

2009-04-02 Thread Tom Lane
Tena Sakai tsa...@gallo.ucsf.edu writes: I often use a line like: psql -tf query.sql mydatabase query.out -t option gets rid of the heading and count report at the bottom. There is a blank line at the bottom, however. Is there any way to have psql not give me that blank line? Doesn't

Re: [SQL] FUNCTION problem

2009-04-02 Thread Peter Willis
Adrian Klaver wrote: Did you happen to catch this: Note that functions using RETURN NEXT or RETURN QUERY must be called as a table source in a FROM clause Try: select * from test_function(1) I did miss that, but using that method to query the function didn't work either. Postgres doesn't

Re: [SQL] FUNCTION problem

2009-04-02 Thread Adrian Klaver
On Thursday 02 April 2009 4:22:06 pm Peter Willis wrote: Adrian Klaver wrote: Did you happen to catch this: Note that functions using RETURN NEXT or RETURN QUERY must be called as a table source in a FROM clause Try: select * from test_function(1) I did miss that, but using that

Re: [SQL] How would I get rid of trailing blank line?

2009-04-02 Thread Tena Sakai
Hi Tom, I am a bit surprised to hear that that '\n' is there unconditionally. But I am sure there are more pressing things for you to work on. It's something I can live with. Regards, Tena Sakai tsa...@gallo.ucsf.edu -Original Message- From: Tom Lane [mailto:t...@sss.pgh.pa.us]

Re: [SQL] How would I get rid of trailing blank line?

2009-04-02 Thread Scott Marlowe
On Thu, Apr 2, 2009 at 3:33 PM, Tena Sakai tsa...@gallo.ucsf.edu wrote: Hi Everybody, I am using postgres 8.3.4 on linux. I often use a line like:   psql -tf query.sql mydatabase query.out -t option gets rid of the heading and count report at the bottom.  There is a blank line at the

Re: [HACKERS] [SQL] How would I get rid of trailing blank line?

2009-04-02 Thread Tena Sakai
Hi Andrew, Right. There's a simple pipeline way to get rid of it: psql -t -f query.sql | sed -e '$d' query.out Hi Scott, Tired of those blank lines in your text files? Grep them away: psql -tf query.sql mydatabase | grep -v ^$ query.out Thank you Both. Regards, Tena Sakai