[GENERAL] getting min/max of two values

2007-09-15 Thread rihad
How can I efficiently return the minimum/maximum of two given expressions? Like SELECT MYMIN(a+b-c,d+e*f). Thanks. ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMA

Re: [GENERAL] Locking entire database

2007-09-15 Thread Panagiwths Pediadiths
Thats the fun part, I actually need to allow duplicates in specific cases but not in this one :) Shouldn't the serializable level prevent these duplicates? As I understand it serializable should give the same result as if the transactions were performed the one after the other. Thnx Panagiotis On

Re: [GENERAL] Locking entire database

2007-09-15 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 09/15/07 03:28, Panagiwths Pediadiths wrote: > Thats the fun part, I actually need to allow duplicates in specific cases > but not in this one :) Same table? > Shouldn't the serializable level prevent these duplicates? As I understand > it seriali

Re: [GENERAL] getting min/max of two values

2007-09-15 Thread Pavel Stehule
2007/9/15, rihad <[EMAIL PROTECTED]>: > How can I efficiently return the minimum/maximum of two given > expressions? Like SELECT MYMIN(a+b-c,d+e*f). > > Thanks. Hello use function GREATEST (maximim) or LEAST (minimum) http://www.postgresql.org/docs/8.2/interactive/functions-conditional.html#AEN1

[GENERAL] strange TIME behaviour

2007-09-15 Thread rihad
Can someone please explain to me why these two give different results? The idea is to get the number of seconds past 00:00:00, so the second one is obviously correct. foo=> select extract(epoch from current_time); date_part -- 42023.026348 (1 row) foo=> select extract(epoch from

Re: [GENERAL] strange TIME behaviour

2007-09-15 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 09/15/07 06:45, rihad wrote: > Can someone please explain to me why these two give different results? > The idea is to get the number of seconds past 00:00:00, so the second > one is obviously correct. How about: select extract(hour from current_t

Re: [GENERAL] strange TIME behaviour

2007-09-15 Thread Michael Fuhr
On Sat, Sep 15, 2007 at 04:45:02PM +0500, rihad wrote: > Can someone please explain to me why these two give different results? > The idea is to get the number of seconds past 00:00:00, so the second > one is obviously correct. They're both correct. > foo=> select extract(epoch from current_tim

Re: [GENERAL] Locking entire database

2007-09-15 Thread hubert depesz lubaczewski
On Fri, Sep 14, 2007 at 04:48:08PM +0300, Panagiotis Pediaditis wrote: > Is there some way of locking all database tables in a transaction > without knowing their names > or even better just locking the entire database? I know this is bad > tactics but there is a specific > case where i need it.

Re: [GENERAL] strange TIME behaviour

2007-09-15 Thread rihad
Michael Fuhr wrote: On Sat, Sep 15, 2007 at 04:45:02PM +0500, rihad wrote: Can someone please explain to me why these two give different results? The idea is to get the number of seconds past 00:00:00, so the second one is obviously correct. They're both correct. foo=> select extract(epoch

Re: [GENERAL] strange TIME behaviour

2007-09-15 Thread Martijn van Oosterhout
On Sat, Sep 15, 2007 at 06:40:38PM +0500, rihad wrote: > PostgreSQL seems to default to "time without time zone" when declaring > columns in the table schema. Since all my times and timestamps are in > local time zone, and I'm *only* dealing with local times, should I be > using "time with time

Re: [GENERAL] strange TIME behaviour

2007-09-15 Thread rihad
Michael Fuhr wrote: On Sat, Sep 15, 2007 at 04:45:02PM +0500, rihad wrote: Can someone please explain to me why these two give different results? The idea is to get the number of seconds past 00:00:00, so the second one is obviously correct. They're both correct. foo=> select extract(epoch

[GENERAL] "like" vs "substring" again

2007-09-15 Thread Christian Schröder
Hi list, last week I asked a question about a query with several joins and a "like" operator which was really slow. When I replaced "like" with "substring" (which was possible because the comparison was simply "bla like '123%'") the query became extremely faster because the query optimizer ca

Re: [GENERAL] strange TIME behaviour

2007-09-15 Thread Tom Lane
Martijn van Oosterhout <[EMAIL PROTECTED]> writes: > Historical I beleive. Postgres has four types: timestamp, timestamptz, > time and timetz. Then SQL decreed that TIMESTAMP means WITH TIME ZONE, > ie timestamptz. So now you get the odd situation where: > timestamp == timestamp with time zone =

[GENERAL] text_pattern_ops index *not* used in field = value condition?

2007-09-15 Thread hubert depesz lubaczewski
i have this table: # \d text_words Table "public.text_words" Column | Type |Modifiers +-+- id | integer | not null default nextval('text_words_id_seq'::regclass) word

Re: [GENERAL] text_pattern_ops index *not* used in field = value condition?

2007-09-15 Thread Tom Lane
hubert depesz lubaczewski <[EMAIL PROTECTED]> writes: > index is created using text_pattern_ops so i will be able to use it in 'where > word like '...%'' > but, it appears it is not usable with = operator: = is not one of the members of the text_pattern_ops operator class. regression=# select am

Re: [GENERAL] text_pattern_ops index *not* used in field = value condition?

2007-09-15 Thread hubert depesz lubaczewski
On Sat, Sep 15, 2007 at 11:09:39AM -0400, Tom Lane wrote: > hubert depesz lubaczewski <[EMAIL PROTECTED]> writes: > > index is created using text_pattern_ops so i will be able to use it in > > 'where word like '...%'' > > but, it appears it is not usable with = operator: > = is not one of the memb

Re: [GENERAL] text_pattern_ops index *not* used in field = value condition?

2007-09-15 Thread Tom Lane
hubert depesz lubaczewski <[EMAIL PROTECTED]> writes: > On Sat, Sep 15, 2007 at 11:09:39AM -0400, Tom Lane wrote: >> = is not one of the members of the text_pattern_ops operator class. > ok, but is there any reason for this? Well, at the time those opclasses were invented, the regular = operator

Re: [GENERAL] text_pattern_ops index *not* used in field = value condition?

2007-09-15 Thread hubert depesz lubaczewski
On Sat, Sep 15, 2007 at 11:48:19AM -0400, Tom Lane wrote: > As of a couple years ago, the regular text = operator only yields true > for bitwise-equal strings, so we could perhaps drop ~=~ and use = in its > place. But I'd be worried about breaking existing queries that expect > the strangely-name

Re: [GENERAL] getting min/max of two values

2007-09-15 Thread Jeff Davis
On Sat, 2007-09-15 at 12:40 +0500, rihad wrote: > How can I efficiently return the minimum/maximum of two given > expressions? Like SELECT MYMIN(a+b-c,d+e*f). > SELECT LEAST(a+b-c,d+e*f); SELECT GREATEST(a+b-c,d+e*f); Regards, Jeff Davis ---(end of broadcast)--

[GENERAL] read-only queries on PITRslaves, any progress?

2007-09-15 Thread Marinos Yannikos
Hello, this might not be the best place to ask, but has there been any further progress or an alternative project to Florian Pflug's SoC 2007 proposal about enabling PITR slaves to serve read-only queries? It seems like an elegant way to load-balance a PostgreSQL database with very little over

Re: [GENERAL] use COPY TO on normalized database

2007-09-15 Thread Sean Davis
Acm wrote: I am working with PostgreSQL 8.2.4. I need to use the SQL COPY (COPY table FROM file) statement to populate my database. I have created a normalized data model (up to 3NF). Is it possible to use COPY TO on a particular table (that is linked to other tables using foreign keys) whilst

Re: [GENERAL] GRANT on group does not give access to group members

2007-09-15 Thread Sean Davis
wild_oscar wrote: Well, after further searching and reviewing the code I believe the problem was the NOINHERIT in the login role creation. So the remaining question is: On another question, if I want to grant privileges to all tables I have to do them ONE BY ONE. Granting the privileges on the

Re: [GENERAL] Locking entire database

2007-09-15 Thread Merlin Moncure
On 9/15/07, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: > On Fri, Sep 14, 2007 at 04:48:08PM +0300, Panagiotis Pediaditis wrote: > > Is there some way of locking all database tables in a transaction > > without knowing their names > > or even better just locking the entire database? I know

[GENERAL] Function to determine next payment date

2007-09-15 Thread Paul Lambert
I'm trying to create a function to determine the next due payment date of a recurring expense. I have a table containing the date the payment first started, and a payment frequency key which relates to a payment ID in another table containing a string defining how frequent the payment exists.

Re: [GENERAL] Function to determine next payment date

2007-09-15 Thread Paul Lambert
Paul Lambert wrote: I'm trying to create a function to determine the next due payment date of a recurring expense. I have a table containing the date the payment first started, and a payment frequency key which relates to a payment ID in another table containing a string defining how frequent

Re: [GENERAL] PostgreSQL Glossary?

2007-09-15 Thread Robert Treat
On Thursday 13 September 2007 14:52, Nikolay Samokhvalov wrote: > Hi all, > > does anybody know where to find a good list of PostgreSQL terms > (including both traditional terms and Postgres-specific ones)? At > least a simple list w/o descriptions... > AFAIK no such thing exists, but someone coul

Re: [GENERAL] Locking entire database

2007-09-15 Thread Panagiwths Pediadiths
On Sat, 15 Sep 2007, Ron Johnson wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 09/15/07 03:28, Panagiwths Pediadiths wrote: > > Thats the fun part, I actually need to allow duplicates in specific cases > > but not in this one :) > > Same table? Yup > > > Shouldn't the serializ

Re: [GENERAL] Locking entire database

2007-09-15 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 09/15/07 19:59, Panagiwths Pediadiths wrote: > > On Sat, 15 Sep 2007, Ron Johnson wrote: > > On 09/15/07 03:28, Panagiwths Pediadiths wrote: Thats the fun part, I actually need to allow duplicates in specific cases but not in this one :)

Re: [GENERAL] Database reverse engineering

2007-09-15 Thread Scott Ribe
Embarcadero's tools are quite nice, quite pricey, Windows only. -- Scott Ribe [EMAIL PROTECTED] http://www.killerbytes.com/ (303) 722-0567 voice ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings