Re: [GENERAL] Sorting street addresses

2004-10-28 Thread Jean-Luc Lachance
How will that work when people reside at 123A Some St. Address that need to be sorted and/or grouped in any way should be stored as multiple fields. door number door number suffix Most often a letter street name prefix Section street name street name suffix Direcetion

Re: [GENERAL] earthdistance is not giving correct results.

2004-10-03 Thread Jean-Luc Lachance
I agree, NS or EW long lat should be the same. I was just pointing to the wrong figure. Also, if ll_to_earth takes lat first, it should report an error for a |lat| 90... Michael Fuhr wrote: On Sat, Oct 02, 2004 at 09:29:16PM -0400, Jean-Luc Lachance wrote: Maybe it would work with the right

Re: [GENERAL] earthdistance is not giving correct results.

2004-10-02 Thread Jean-Luc Lachance
Maybe it would work with the right long lat... try Protland OR -122.67555, 45.51184 Seattle WA -122.32956, 47.60342 Also, do not forget that it is the line distance not the driving distance. Michael Fuhr wrote: On Sat, Oct 02, 2004 at 07:09:25PM -0400, Tom Lane wrote: mike cox [EMAIL PROTECTED]

Re: [GENERAL] Random not so random

2004-10-01 Thread Jean-Luc Lachance
Use a SERIAL id on messages, then Select * from messages where id = int8( random() * currval({sequence_name})); Arnau Rebassa wrote: Hi everybody, I'm doing the following query: select * from messages order by random() limit 1; in the table messages I have more than 200 messages and a lot of

Re: [GENERAL] division by zero issue

2004-09-15 Thread Jean-Luc Lachance
Add : AND count(user_tasks.task_id) 0 in the where clause. Greg Donald wrote: Converting some MySQL code to work with Postgres here. I have this query: SELECT tasks.task_id, (tasks.task_duration * tasks.task_duration_type / count(user_tasks.task_id)) as hours_allocated FROM tasks LEFT JOIN

Re: [GENERAL] 'order by' in an insert into command

2004-09-08 Thread Jean-Luc Lachance
Try: insert into pending_tnmt_sec select tseceventid, tsecsecno, nextval('sec_seq'), tsecrtddt from ( select tseceventid, tsecsecno, tsecrtddt from tnmtsec order by tsecrtddt,tseceventid,tsecsecno) as ss; Mike Nolan wrote: I have the following insert to populate a new table: insert into

Re: [GENERAL] tablespace spec

2004-07-29 Thread Jean-Luc Lachance
http://developer.postgresql.org Bruce Momjian wrote: David Parker wrote: Is there a spec/posting somewhere that more or less reflects how tablespaces are supposed to work in 7.5? I've found a lot of info on it by searching the archives, but I haven't found the posting that describes the basic

Re: [GENERAL] get first / last date of given week

2004-07-17 Thread Jean-Luc Lachance
Lee, Have a look at this simpler non looping version of week_start() -- return the first date in the given week CREATE or REPLACE FUNCTION week_start(integer, integer) RETURNS date LANGUAGE 'plpgsql' AS ' DECLARE pyear ALIAS FOR $1; pweek ALIAS FOR $2; year_start date; week_interval

Re: [GENERAL] Table partitioning for maximum speed?

2003-10-10 Thread Jean-Luc Lachance
BULL. How many times does PG have to scan the whole table because of MVCC? At least with partitioning there is a fighting chance that that won't be necessary. Queries that involve the field on which the table is partitioned execute faster by an order of magnitude. It also helps with vaccuming as

Re: [GENERAL] Table partitioning for maximum speed?

2003-10-10 Thread Jean-Luc Lachance
Jean-Luc Lachance wrote: BULL. How many times does PG have to scan the whole table because of MVCC? At least with partitioning there is a fighting chance that that won't be necessary. Queries that involve the field on which the table is partitioned execute faster by an order of magnitude

Re: [GENERAL] why does count take so long?

2003-09-10 Thread Jean-Luc Lachance
or whatever and the commited tuples deleted (all this with appropriate locks). I am not sure if there is a need for the update count. JLL Christopher Browne wrote: In the last exciting episode, [EMAIL PROTECTED] (Jean-Luc Lachance) wrote: How about keeping counts of inserts, deletes and updates

Re: [GENERAL] why does count take so long?

2003-09-09 Thread Jean-Luc Lachance
How about keeping counts of inserts, deletes and updates per table per transaction as part of the live statistics? Tom Lane wrote: I said: Greg Stark [EMAIL PROTECTED] writes: Things like count(*) could use int4 until it overflows though. I don't see a reasonable way for an aggregate

Re: [GENERAL] Monthly table partitioning for fast purges?

2003-08-05 Thread Jean-Luc Lachance
I second that. I have discussed adding partitioning tables almost a year ago... No need to partition a functional index or anything like that. Just partition on a specific field. Ron Johnson wrote: [...] Partitioning should be put on the TODO list soon after tablespaces (or DBA-defined

Re: [GENERAL] Postgresql FIFO Tables, How-To ?

2003-07-16 Thread Jean-Luc Lachance
OUCH!!! Do a COUNT(*) on a 10M row table Forget it. Here is a simple solution. Add a SERIAL field to the table. Set the maximum value for that sequence to the number of records you want to keep. Use a before insert trigger to replace the insert with an update if the key already exist. No

Re: [GENERAL] A creepy story about dates. How to prevent it?

2003-06-19 Thread Jean-Luc Lachance
Shouldn't dates be validated using the *LOCALE setting and not try to guess? Tom Lane wrote: Frank Miles [EMAIL PROTECTED] writes: If the application always passes the date to Postgres with the three-letter month name where appropriate, and use the 4-digit year, it should be