Re: [SQL] is it easy to change the create sequence algorithm?

2002-06-21 Thread Andrew Hammond
Well, the quickest solution I can think of off hand is to not use SERIAL. Instead, do it manually, like this: DROP SEQUENCE my_seq; CREATE SEQUENCE my_seq; DROP TABLE my_table; CREATE TABLE my_table ( my_table_id INTEGER DEFAULT nextval('my_seq') PRIMARY KEY, ... ); Kevin Branne

[SQL] Can somebody help me to optimize this huge query?

2002-06-21 Thread Dirk Lutzebaeck
Hi, here is a query on two tables whith lots of self joins which just takes hours to complete on 7.2.1. I use multi dimensional indices which are shown in the explain comments. My question is how can I use explicit join syntax to let the planner do better. I think Geoq does not match yet because

Re: [SQL] is it easy to change the create sequence algorithm?

2002-06-21 Thread Josh Berkus
Kevin, > I see in the docs that when I create a column that is of type SERIAL, > the engine automatically creates the sequence for me, named > TABLE_COLUMN_seq. That's great until the table name + column name > lengths are > 27 chars, then it starts chopping, and you guessed it, > I have multipl

Re: [SQL] skip weekends

2002-06-21 Thread Josh Berkus
Rudi, > Nice reply Josh. > I wouldn't call your solution 'ugly' at all. Actually I posed te question, and Joe Conway offered the solution. I'll be testing and reporting back. > It's an excellent example of a real world need for Postgresql > functions. > I've also been looking at other function

Re: [SQL] SQL Challenge: Skip Weekends

2002-06-21 Thread Josh Berkus
Joe, > How about this (a bit ugly, but I think it does what you want -- > minus the holidays, which you said you already have figured out): > > create or replace function > get_future_work_day(timestamp, int) Thank you. Once again, you come to the rescue when I'm stuck. I'll try your soluti

Re: [SQL] SQL Challenge: Skip Weekends

2002-06-21 Thread Josh Berkus
Jean-Luc, > date := now - day_of_the_week > interval := interval + day_of_the_week > date := date + int( interval/5)x7 + ( interval mod 5) Merci, merci, merci! -Josh ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send a

[SQL] FW: RESTORE A TABLE

2002-06-21 Thread Jie Liang
I have serveral tables that they have more then 2 millions, I want dump they out from one server and then restore them back on another server every day, the questions are: 1. What is the fastest way to dump/restore my data, I am try to use: pg_dump -aRt mytable -Fc -f mytable dbname pg_res

Re: [SQL] SQL Challenge: Skip Weekends

2002-06-21 Thread Jean-Luc Lachance
here is the algorithm: date := now - day_of_the_week interval := interval + day_of_the_week date := date + int( interval/5)x7 + ( interval mod 5) Josh Berkus wrote: > > Folks, > > Hey, I need to write a date calculation function that calculates the date > after a number of *workdays* from a s

[SQL] Presenting consistent data

2002-06-21 Thread Ian Lynagh
Hi all, Suppose I have two tables, pluses and minuses, and for any given id I maintain the invariant sum(pluses.plus) - sum(minuses.minus) = 0 At a given point in time the tables may be like this: pluses idplus desc 1 100 'a' 1 150 'b' 1 25 'c' 2 80 'a'

[SQL] is it easy to change the create sequence algorithm?

2002-06-21 Thread Kevin Brannen
I see in the docs that when I create a column that is of type SERIAL, the engine automatically creates the sequence for me, named TABLE_COLUMN_seq. That's great until the table name + column name lengths are > 27 chars, then it starts chopping, and you guessed it, I have multiple table/column

Re: [SQL] Joining three data sources.

2002-06-21 Thread Janning Vygen
Am Mittwoch, 19. Juni 2002 16:09 schrieb Masaru Sugawara: > On Wed, 19 Jun 2002 12:33:47 +0200 > > Janning Vygen <[EMAIL PROTECTED]> wrote: > > - > > Result Inter Mailand vs. AC ROM 2:1 > > team1_id|team2_id|goals1|goals2 > > 1 2 2 1 > > SELECT go1.game_id,

[SQL] rowtype and ecpg

2002-06-21 Thread Alla
I have a function that takes as a parameter ROWTYPE: create or replace function test_func(test_table) returns varchar as ' declare lv_return varchar; begin .. return lv_return; end; ' LANGUAGE 'plpgsql'; How do I call this function from the C program (ecpg)? How my declaration sh

Re: [SQL] [ADMIN] Incredible..

2002-06-21 Thread Larry Rosenman
ts/viruses.phtml?vid=75 And this mail from my virus scanner: > A virus was found in an email from: <[EMAIL PROTECTED]> The message was addressed to: -> <[EMAIL PROTECTED]> The message has been quarantined as: /var/virusmails/virus-20020621-104030-30552 Here is the outp

Re: [SQL] [ADMIN] Incredible..

2002-06-21 Thread Cliff Wells
On Fri, 21 Jun 2002 09:57:20 -0500 Luis Andaluz P, wrote: > Hello, > see this interesting file. > Bye. > And see this interesting URL: http://www.brocku.ca/its/helpdesk/virusalerts/viruses.phtml?vid=75 -- Cliff Wells, Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x

Re: [SQL] Optimizer question with equivalent joins

2002-06-21 Thread Tom Lane
Dirk Lutzebaeck <[EMAIL PROTECTED]> writes: > say I have a join which says > t.a = t.b and t.b = t.c > do I need to give the optimizer a hint by saying it more redundantly > t.a = t.b and t.b = t.c and t.c = t.a Not since about 7.0.3 ... regards, tom lane ---

[SQL] Optimizer question with equivalent joins

2002-06-21 Thread Dirk Lutzebaeck
Hello, say I have a join which says t.a = t.b and t.b = t.c do I need to give the optimizer a hint by saying it more redundantly t.a = t.b and t.b = t.c and t.c = t.a or is this just counter productive because there is one more join? In the real world I have 10-20 equivalent joins w

Re: [SQL] how to sort a birthday list ?

2002-06-21 Thread Jan Wieck
Bruno Wolff III wrote: > > On Fri, Jun 21, 2002 at 10:30:54 +0200, > Michael Agbaglo <[EMAIL PROTECTED]> wrote: > > > > of course you could sort by DOY but then you'll have a problem w/ the > > next year: > > > > if it's let's say december and you select the list for the next 60 days, > > perso

Re: [SQL] how to sort a birthday list ?

2002-06-21 Thread Bruno Wolff III
On Fri, Jun 21, 2002 at 10:30:54 +0200, Michael Agbaglo <[EMAIL PROTECTED]> wrote: > > of course you could sort by DOY but then you'll have a problem w/ the > next year: > > if it's let's say december and you select the list for the next 60 days, > persons having birthday in december will app

Re: [SQL] date_ge and time_ge

2002-06-21 Thread Achilleus Mantzios
On Fri, 21 Jun 2002 [EMAIL PROTECTED] wrote: > Hello > > I have a question regarding date_ge() and time_ge(). > > This statement works : > > select * from userlog where date_ge(ul_timestamp, '20.06.2002') > > > This statement doesn't work : > > select * from userlog where time_ge(ul_timesta

[SQL] date_ge and time_ge

2002-06-21 Thread juerg . rietmann
Hello I have a question regarding date_ge() and time_ge(). This statement works : select * from userlog where date_ge(ul_timestamp, '20.06.2002') This statement doesn't work : select * from userlog where time_ge(ul_timestamp, '08:00:00') Here are some records from userlog : (See attached

Re: [SQL] how to sort a birthday list ?

2002-06-21 Thread Michael Agbaglo
David Stanaway wrote: > > How about: > ORDER BY dateofbirth > > > doesn't work: it's sorted by YEAR ... ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] how to sort a birthday list ?

2002-06-21 Thread Michael Agbaglo
Dear Josh, if you sort by AGE then the order will be young -> old or vice versa. I'd like to have the list sorted as interval birthDAY, birthMONTH and DAY from NOW() and MONTH from NOW(). example: 22.06.64 Person-1 26.06.50 Person-2 01.08.69 Person-3 02.08.71 Person-4 ... of course you could

Re: [SQL] skip weekends

2002-06-21 Thread Cliff Wells
On Thu, 2002-06-20 at 23:08, Rudi Starcevic wrote: > Hello, > > Nice reply Josh. > I wouldn't call your solution 'ugly' at all. > > It's an excellent example of a real world need for Postgresql functions. > I've also been looking at other functions at > http://www.brasileiro.net/postgres/cookbo